humanize
July 4th, 2009 by RadarI was inspired earlier in the year by Brenton Fletcher’s humanize that I decided to make my own. Today, I “finished” it with the help of Mitchell Riley and other Actionhackers. Humanize will convert numbers up to a very large number of digits long into their string versions. This means given the number:
444,333,222,111,999,777,666,555,444,333,222,111,999,777,666,555,444,333,221,111,112,176,514,321,007,310, 444,333,222,111,999,777,666,555,444,333,222,111,999,777,666,555,444,333,221,111,112,176,514,321,007,310
Yes it’s the same sequence repeated twice, I got lazy in my testing. imagine it conjoined into one very large number.
Coincidentally, this is my IQ.
I get:
four hundred and forty four quinquagintillion, three hundred and thirty three novenquadragintillion, two hundred and twenty two octoquadragintillion, one hundred and eleven septenquadragintillion, nine hundred and ninety nine sesquadragintillion, seven hundred and seventy seven quinquadragintillion, six hundred and sixty six quattuorquadragintillion, five hundred and fifty five trequadragintillion, four hundred and forty four duoquadragintillion, three hundred and thirty three unquadragintillion, two hundred and twenty two quadragintillion, one hundred and eleven novemtrigintillion, nine hundred and ninety nine octotrigintillion, seven hundred and seventy seven septentrigintillion, six hundred and sixty six sextrigintillion, five hundred and fifty five quintrigintillion, four hundred and forty four quattuortrigintillion, three hundred and thirty three trestrigintillion, two hundred and twenty one duotrigintillion, one hundred and eleven untrigintillion, one hundred and twelve trigintillion, one hundred and seventy six novemvigintillion, five hundred and fourteen octovigintillion, three hundred and twenty one septenvigintillion, seven sexvigintillion, three hundred and ten quinvigintillion, four hundred and forty four quattuortillion, three hundred and thirty three trevigintillion, two hundred and twenty two duovigintillion, one hundred and eleven unvigintillion, nine hundred and ninety nine vigintillion, seven hundred and seventy seven novemdecillion, six hundred and sixty six octodecillion, five hundred and fifty five septendecillion, four hundred and forty four sexdecillion, three hundred and thirty three quindecillion, two hundred and twenty two quattuordecillion, one hundred and eleven tredecillion, nine hundred and ninety nine duodecillion, seven hundred and seventy seven undecillion, six hundred and sixty six decillion, five hundred and fifty five nonillion, four hundred and forty four octillion, three hundred and thirty three septillion, two hundred and twenty one sextillion, one hundred and eleven quintrillion, one hundred and twelve quadrillion, one hundred and seventy six trillion, five hundred and fourteen billion, three hundred and twenty one million, seven thousand three hundred and ten.
Props to this site which gives names to unimaginably large numbers.
I have yet to find a use for this, but I’m sure somebody out there can.
NOW WITH FASTER PEFORMANCE! Thanks to Jack Chen.
Tags: ruby

July 5th, 2009 at 2:26 am
Now you just need it to have compatibility modes to contend with the difference between US, UK, and EU naming =P
July 5th, 2009 at 2:26 am
Oh, and yes, that is a challenge.
July 5th, 2009 at 4:24 am
Just a suggestion before this post gets cached in Google – I think if you look at the digits below 10^15 and compare them to the text version, you’ll notice some, er, irregularities, shall we say?
“…one hundred and twelve quadrillion, one hundred and seventy six trillion, five hundred and fourteen billion, three hundred and twenty one million, seven thousand three hundred and ten” should lead to a number that terminates with “…,112,176,514,321,007,310″, which isn’t the number you’ve posted. That number also appears to be 156 digits in size; not sure if the “50 digits” restriction is correct from your post.
July 5th, 2009 at 9:16 am
How does it go with the numbers after the decimal place?
July 5th, 2009 at 10:14 am
It works with numbers after the decimal place, “point one four five” for any number ending in .145.
July 5th, 2009 at 10:20 am
@ Mark: the number was massacred when I tried putting in the , separators. Now it is correct.
July 7th, 2009 at 1:06 am
You have raised a challenge that shall be met… I’ll post my response tomorrow!
July 8th, 2009 at 5:42 pm
Just an update: bench.rb now runs at 0.4 sec on Ruby 1.9, 0.7 on Ruby 1.8
July 14th, 2009 at 11:53 am
And by tomorrow I meant soon – still a work on progress.