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
[ [ 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
[ 1000000over /modsize swap0 triplet> 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 ] is name$ ( n --> $ )
dup reverse witheach
[ char , = if
[ i split
behead drop
$ " and" swap
join join
conclude ] ] ] is name$ ( n --> $ )
 
10 times
[ 10 918 random
1+ ** random
dup echo
say " is:"
name$ nest$
60 wrap$ cr cr ]</syntaxhighlight>
</syntaxhighlight>
 
{{out}}
 
<pre>1272741791 is:
onetwo million, seven hundred, andfourty one twentythousand, seven
hundred and ninety one
 
380004 is:
four
thirty eight thousand
 
76818288663798714 is:
seven hundred and sixty eightthree million, oneseven hundred, andninety eight thousand,
eighty two thousand, eightseven hundred and eighty sixfourteen
 
1777100851236 is:
seven hundred, seventy seven billion, one hundred million,
one
eight hundred, fifty one thousand, two hundred and thirty
six
 
36076073689199513 is:
three millionbillion, six hundred, andeighty sevennine thousandmillion, six hundredone
hundred, ninety nine thousand, five hundred and thirteen
and seven
 
5059697703514386370 is:
fiveseven millionhundred, fiftythree nine thousandbillion, sixfive hundred, and ninetyfourteen
million, three hundred, eighty six thousand, three hundred
seven
and seventy
 
96896829121545842 is:
ninetwenty hundred and sixty eightone million, ninefive hundred, andfourty sixtyfive thousand,
eight thousand, two hundred and ninetyfourty onetwo
 
251626133867 is:
twentythree five millionthousand, oneeight hundred and sixty two thousand, sixseven
hundred and thirteen
 
4581964814902020 is:
four hundredmillion, andnine fifty eight millionhundred, onetwo hundredthousand and ninetytwenty
six thousand, four hundred and eighty one
 
47022976290599343 is:
4493774 is:
fourty seven quadrillion, twenty two trillion, nine hundred,
four million, four hundred and ninety three thousand, seven
seventy six billion, two hundred, ninety million, five
hundred and seventy four
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 9999991000000 do
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="ecmascriptwren">var small = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven",
"twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
 
1,983

edits