Jump to content

Number names: Difference between revisions

→‎{{header|Quackery}}: extended valid range, improved comma/and logic.
(Added BASIC256)
(→‎{{header|Quackery}}: extended valid range, improved comma/and logic.)
Line 5,582:
{{trans|C#}}
 
<syntaxhighlight lang="quackery">[ [ table
[ [ table
$ "zero" $ "one" $ "two"
$ "three" $ "four" $ "five"
Line 5,591 ⟶ 5,590:
$ "fourteen" $ "fifteen"
$ "sixteen" $ "seventeen"
$ "eighteen" $ "nineteen" ] do ] is units ( n --> $ )
 
[ [ table
Line 5,597 ⟶ 5,596:
$ "thirty" $ "fourty" $ "fifty"
$ "sixty" $ "seventy" $ "eighty"
$ "ninety" ] do ] is tens ( n --> $ )
 
[ $ "" swap
Line 5,614 ⟶ 5,613:
[ 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,651:
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 seventyninety fourone
 
38000 is:
thirty eight thousand
 
7681828864 is:
four
seven hundred and sixty eight million, one hundred and
eighty two thousand, eight hundred and eighty six
 
163798714 is:
sixty three million, seven hundred, ninety eight thousand,
one
seven hundred and fourteen
 
3607607777100851236 is:
threeseven millionhundred, six hundred andseventy seven thousandbillion, sixone hundred million,
fiveeight millionhundred, fifty nineone thousand, sixtwo hundred and ninetythirty
and seven
six
 
50596973689199513 is:
three billion, six hundred, eighty nine million, one
five million, fifty nine thousand, six hundred and ninety
eightyhundred, twoninety nine thousand, eightfive hundred and eighty sixthirteen
seven
 
968968291703514386370 is:
nineseven hundred, andthree sixty eight millionbillion, ninefive hundred, and sixtyfourteen
million, three hundred, eighty six thousand, three hundred
eight thousand, two hundred and ninety one
and seventy
 
2516261321545842 is:
twenty fiveone million, onefive hundred, andfourty sixty twofive thousand, six
eight hundred and thirteenfourty two
 
4581964813867 is:
fourthree hundred and fiftythousand, eight million, one hundred and ninetysixty seven
six thousand, four hundred and eighty one
 
44937744902020 is:
four million, fournine hundred, andtwo ninetythousand three thousand,and seventwenty
hundred and seventy four
 
47022976290599343 is:
</pre>
fourty seven quadrillion, twenty two trillion, nine hundred,
seventy six billion, two hundred, ninety million, five
sixhundred, ninety nine thousand, fourthree hundred and eighty onefourty
three</pre>
 
=={{header|R}}==
1,462

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.