Number names: Difference between revisions

Content added Content deleted
(Added BASIC256)
(→‎{{header|Quackery}}: extended valid range, improved comma/and logic.)
Line 5,582: Line 5,582:
{{trans|C#}}
{{trans|C#}}


<syntaxhighlight lang="quackery">
<syntaxhighlight lang="quackery">[ [ table
[ [ table
$ "zero" $ "one" $ "two"
$ "zero" $ "one" $ "two"
$ "three" $ "four" $ "five"
$ "three" $ "four" $ "five"
Line 5,591: Line 5,590:
$ "fourteen" $ "fifteen"
$ "fourteen" $ "fifteen"
$ "sixteen" $ "seventeen"
$ "sixteen" $ "seventeen"
$ "eighteen" $ "nineteen" ] do ] is units ( n --> $ )
$ "eighteen" $ "nineteen" ] do ] is units ( n --> $ )


[ [ table
[ [ table
Line 5,597: Line 5,596:
$ "thirty" $ "fourty" $ "fifty"
$ "thirty" $ "fourty" $ "fifty"
$ "sixty" $ "seventy" $ "eighty"
$ "sixty" $ "seventy" $ "eighty"
$ "ninety" ] do ] is tens ( n --> $ )
$ "ninety" ] do ] is tens ( n --> $ )


[ $ "" swap
[ $ "" swap
Line 5,614: Line 5,613:
[ over -1 peek space != if
[ over -1 peek space != if
[ dip [ space join ] ] ]
[ dip [ space join ] ] ]
units join ] is triplet ( n --> $ )
units join ] is triplet ( n --> $ )


[ $ "" swap
[ $ "" 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
dup 999999 > if
[ 1000000 /mod swap triplet
[ over size 0 > if
[ dip [ $ ", " join ] ]
1000000 /mod swap triplet
$ " million" join
$ " million" join
swap dip join
swap dip join
Line 5,631: Line 5,651:
over size 0 > if
over size 0 > if
[ dip [ $ ", " join ] ]
[ dip [ $ ", " join ] ]
triplet join ] is name$ ( n --> $ )
triplet join
dup reverse witheach
[ char , = if
[ i split
behead drop
$ " and" swap
join join
conclude ] ] ] is name$ ( n --> $ )


10 times
10 times
[ 10 9 random
[ 10 18 random
1+ ** random
1+ ** random
dup echo
dup echo
say " is:"
say " is:"
name$ nest$
name$ nest$
60 wrap$ cr cr ]
60 wrap$ cr cr ]</syntaxhighlight>
</syntaxhighlight>


{{out}}
{{out}}


<pre>127 is:
<pre>2741791 is:
one hundred and twenty seven
two million, seven hundred, fourty one thousand, seven
hundred and ninety one

38000 is:
thirty eight thousand


768182886 is:
4 is:
four
seven hundred and sixty eight million, one hundred and
eighty two thousand, eight hundred and eighty six


1 is:
63798714 is:
sixty three million, seven hundred, ninety eight thousand,
one
seven hundred and fourteen


3607607 is:
777100851236 is:
three million, six hundred and seven thousand, six hundred
seven hundred, seventy seven billion, one hundred million,
eight hundred, fifty one thousand, two hundred and thirty
and seven
six


5059697 is:
3689199513 is:
three billion, six hundred, eighty nine million, one
five million, fifty nine thousand, six hundred and ninety
hundred, ninety nine thousand, five hundred and thirteen
seven


968968291 is:
703514386370 is:
nine hundred and sixty eight million, nine hundred and sixty
seven hundred, three billion, five hundred, fourteen
million, three hundred, eighty six thousand, three hundred
eight thousand, two hundred and ninety one
and seventy


25162613 is:
21545842 is:
twenty five million, one hundred and sixty two thousand, six
twenty one million, five hundred, fourty five thousand,
hundred and thirteen
eight hundred and fourty two


458196481 is:
3867 is:
four hundred and fifty eight million, one hundred and ninety
three thousand, eight hundred and sixty seven
six thousand, four hundred and eighty one


4493774 is:
4902020 is:
four million, four hundred and ninety three thousand, seven
four million, nine hundred, two thousand and twenty
hundred and seventy four


47022976290599343 is:
</pre>
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}}==
=={{header|R}}==