Ticket #10 (closed defect: invalid)

Opened 20 months ago

Last modified 20 months ago

numwords uses unnecessary conjunctions

Reported by: cayblood Owned by: deveiant
Priority: normal Milestone:
Component: English Version: 1.0.3
Severity: normal Keywords:
Cc:

Description (last modified by deveiant) (diff)

In American English, the "and"s before tens and one should be omitted. From wikipedia:

"Note that in American English, it is non-standard to use the word and before tens and ones. It is instead used as a verbal delimiter when dealing with compound numbers. Thus, instead of 'three hundred and seventy-three', Americans usually say (and write) 'three hundred seventy-three'." ( Wikipedia: http://en.wikipedia.org/wiki/Names_of_numbers_in_English )

For example, 264 comes out like this:

nine quintillion, two hundred and twenty-three quadrillion, three hundred and seventy-two trillion, thirty-six billion, eight hundred and fifty-four million, seven hundred and seventy-five thousand, eight hundred and eight

Instead, it should be:

nine quintillion, two hundred twenty-three quadrillion, three hundred seventy-two trillion, thirty-six billion, eight hundred fifty-four million, seven hundred seventy-five thousand, eight hundred eight

Change History

Changed 20 months ago by deveiant

  • status changed from new to closed
  • version set to 1.0.3
  • resolution set to invalid
  • description modified (diff)

You are presuming that the library should aspire to produce text which follows the American English convention according to Wikipedia, which it does not.

However, you can make it follow whatever convention you prefer with a little effort. You you'll find what you need in the documentation for the #numwords method:

:and
Set the word and/or characters used where ' and ' (the default) is normally used. Setting :and to ' ', for example, will cause 2556 to be returned as "two-thousand, five hundred fifty-six" instead of "two-thousand, five hundred and fifty-six".

So, to use (a slightly modified version of) your example:

irb(main):001:0> (2 ** 63).numwords
=> "nine quintillion, two hundred and twenty-three quadrillion, three
hundred and seventy-two trillion, thirty-six billion, eight hundred and
fifty-four million, seven hundred and seventy-five thousand, eight hundred
and eight"

irb(main):002:0> (2 ** 63).numwords( :and => ' ' )
=> "nine quintillion, two hundred twenty-three quadrillion, three hundred
seventy-two trillion, thirty-six billion, eight hundred fifty-four million,
seven hundred seventy-five thousand, eight hundred eight"

You can also make it follow the Associated Press convention ("![...] do not use commas between other separate words that are part of one number"):

irb(main):003:0> (2 ** 63).numwords( :and => ' ', :comma => ' ' )
=> "nine quintillion two hundred twenty-three quadrillion three hundred
seventy-two trillion thirty-six billion eight hundred fifty-four million
seven hundred seventy-five thousand eight hundred eight"

I find both the form you suggest and the AP convention to be less readable, so the default includes both commas and an "and".

Note: See TracTickets for help on using tickets.