muba has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

This is not really a Perl question, although I need it for a script I'm writing. What it does is, you pass a number to it (for example '1435') and then it returns 'one thousand thirty five'. Well, this works, actually :) The question is, what parts are concatenated.
For example, do you write "thirty five", "thirty-five" or "thirtyfive"? Same goes for 400: "four hundred" or "fourhundred"? And what about 430: "four hundred thirty", "fourhundred thirty", "four hundredthirty" etc... Same goes for 1100: "one\s?thousand\s?one\s?hundred".

So, could anyone please give me a rule of thumb how this is done? Thank you :)

  • Comment on [not really perl] How to spell numbers?

Replies are listed 'Best First'.
Re: [not really perl] How to spell numbers?
by halley (Prior) on Mar 23, 2004 at 13:39 UTC
    Check CPAN for a module called Lingua::EN::Numbers for spelling numbers by (American) English rules.

    It only spells them cardinally (one two three), not ordinally (first second third), but it can handle negative numbers and decimal fractions.

    Update: You changed your question while I composed my response. For basic English rules, I suggest a book like the Chicago Manual of Style, or Elements of Style, or Garner's Modern American Usage.

    --
    [ e d @ h a l l e y . c c ]

      Hmm... I was checking out a FAQ of Chicago Manual of Style and they use the styles mixed up themselves. For example, they give one example in which they both use "twenty one" and "twenty-one". But, as it appears to me, it's most common to just put a space between every single unit (one hundred, six hundred, four hundred eighty four). So... until I find a resource which is more consistent, I'll do it this way.

      Thank you for your hint, anyway.
Re: [not really perl] How to spell numbers?
by BrowserUk (Patriarch) on Mar 23, 2004 at 13:58 UTC

    There's some advice here. I googled for "Grammar writing numbers"


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
      Ok. This one suggests to write any numbers between twenty-one and ninety-nine with hyphens. So does my script, now. All other units are still seperated by a space character.
      Thank you, BrowserUk.