Number names: Difference between revisions
Added Easylang
(Added BASIC256) |
(Added Easylang) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 2,082:
Readln;
end.</syntaxhighlight>
=={{header|EasyLang}}==
{{trans|Go}}
<syntaxhighlight>
small$[] = [ "zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" "seventeen" "eighteen" "nineteen" ]
tens$[] = [ "" "" "twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety" ]
illions$[] = [ "" " thousand" " million" " billion" " trillion" " quadrillion" " quintillion" ]
func$ say n .
if n < 0
t$ = "negative "
n = -n
.
if n < 20
t$ &= small$[n + 1]
elif n < 100
t$ &= tens$[n div 10 + 1]
s = n mod 10
if s > 0
t$ &= "-" & small$[s + 1]
.
elif n < 1000
t$ &= small$[n div 100 + 1] & " hundred"
s = n mod 100
if s > 0
t$ &= " " & say s
.
else
i = 1
while n > 0
p = n mod 1000
n = n div 1000
if p > 0
ix$ = say p & illions$[i]
if sx$ <> ""
ix$ &= " " & sx$
.
sx$ = ix$
.
i += 1
.
t$ &= sx$
.
return t$
.
for n in [ 12 1048576 9e18 -2 0 ]
print say n
.
</syntaxhighlight>
{{out}}
<pre>
twelve
one million forty-eight thousand five hundred seventy-six
nine quintillion
negative two
zero
</pre>
=={{header|Ecstasy}}==
Line 5,582 ⟶ 5,638:
{{trans|C#}}
<syntaxhighlight lang="quackery">[ [ table
$ "zero" $ "one" $ "two"
$ "three" $ "four" $ "five"
Line 5,591 ⟶ 5,646:
$ "fourteen" $ "fifteen"
$ "sixteen" $ "seventeen"
$ "eighteen" $ "nineteen" ] do ] is units ( n --> $ )
[ [ table
Line 5,597 ⟶ 5,652:
$ "thirty" $ "fourty" $ "fifty"
$ "sixty" $ "seventy" $ "eighty"
$ "ninety" ] do ] is tens ( n --> $ )
[ $ "" swap
Line 5,614 ⟶ 5,669:
[ over -1 peek space != if
[ dip [ space join ] ] ]
units join ] is triplet ( n --> $ )
[ $ "" swap
dup 999999999999999 > if
[ 1000000000000000 /mod swap triplet
$ " quadrillion" join
swap dip join
dup 0 = iff drop ]done[ ]
dup 999999999999 > if
[ over size 0 > if
[ dip [ $ ", " join ] ]
1000000000000 /mod swap triplet
$ " trillion" join
swap dip join
dup 0 = iff drop ]done[ ]
dup 999999999 > if
[ over size 0 > if
[ dip [ $ ", " join ] ]
1000000000 /mod swap triplet
$ " billion" join
swap dip join
dup 0 = iff drop ]done[ ]
dup 999999 > if
[
[ dip [ $ ", " join ] ]
1000000 /mod swap triplet
$ " million" join
swap dip join
Line 5,631 ⟶ 5,707:
over size 0 > if
[ dip [ $ ", " join ] ]
triplet join
dup reverse witheach
[ char , = if
[ i split
behead drop
$ " and" swap
join join
conclude ] ] ] is name$ ( n --> $ )
10 times
[ 10
1+ ** random
dup echo
say " is:"
name$ nest$
60 wrap$ cr cr ]</syntaxhighlight>
{{out}}
<pre>
hundred and ninety one
four
seven hundred, seventy seven billion, one hundred million,
eight hundred, fifty one thousand, two hundred and thirty
six
three
hundred, ninety nine thousand, five hundred and thirteen
million, three hundred, eighty six thousand, three hundred
and seventy
eight
four
47022976290599343 is:
fourty seven quadrillion, twenty two trillion, nine hundred,
seventy six billion, two hundred, ninety million, five
hundred, ninety nine thousand, three hundred and fourty
three</pre>
=={{header|R}}==
Line 6,514 ⟶ 6,598:
var integer: number is 0;
begin
for number range 1 to
writeln(str(ENGLISH, number));
end for;
Line 7,361 ⟶ 7,445:
{{trans|Go}}
Although the third example here works correctly, it is not safe to use this script for numbers with an absolute magnitude >= 2^53 as integers cannot be expressed exactly by Wren's Num type beyond that limit.
<syntaxhighlight lang="
"twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
|