5

as part of a project I am working on, I need to output the alphabetical 'name' of the number. This is better illustrated with an example.

960
Nine Hundred and Sixty

So it'd convert '960' to 'Nine Hundred and Sixty'. Is there an easy way to do this in C#.NET? Also, if so, how easy would it be to apply the same function to a decimal number? I'm assuming if I can figure out how to convert a integer as above, I can just split the decimal number... so I'd have something like this

960.23

Nine Hundred and Sixty (units) and Twenty Three (units)

Community
  • 1
  • 1
Chris
  • 7,415
  • 21
  • 98
  • 190
  • 2
    Technically speaking, the and should only come in to play when there's a decimal point...or so I was taught in school. – Brad Christie Feb 10 '11 at 16:12
  • 3
    This is a syntax nitpick, but the word 'and' in a numeric readout represents the decimal point - so "Nine Hundred and Sixty" would be 900.60 - not 960.00. – Erik Forbes Feb 10 '11 at 16:14
  • 2
    Agreed. Pedantically, "962.231" would be "Nine hundred sixty-two and two hundred thirty-one thousandths" – Justin Feb 10 '11 at 16:16
  • 2
    This sounds like a classroom assignment I used to give my C++ students, this isn't for an assignment is it? Check writing? – James Michael Hare Feb 10 '11 at 16:20
  • Here is a gode golf answer you might be interested in: http://stackoverflow.com/questions/309884/code-golf-number-to-words/408776#408776 – Brandon Feb 10 '11 at 16:21
  • @Brad, @Erik, @Justin: That really depends on what dialect you're speaking: In British English that would read as "nine hundred and sixty point two three". – LukeH Feb 10 '11 at 16:22
  • @Brad @Erik @Justin: That's an american-specific "rule" which as far as I can tell is not followed very much: http://english.stackexchange.com/questions/3518/american-vs-british-english-meaning-of-one-hundred-and-fifty – Blorgbeard Feb 10 '11 at 16:23
  • Thanks all - I'm well past being a student by the way! – Chris Feb 10 '11 at 16:26
  • @Chris then you you should be able to post your attempt at doing this. Just seems like this has no real world solution. Any solution would have to be cultural specfic for obvious reasons. – Security Hound Feb 10 '11 at 17:31
  • @LukeH, @Blorg - Thanks, I was unaware of the cultural distinction. =) – Erik Forbes Feb 10 '11 at 18:09
  • I'm replicating a report that needs to be generated, and in that report it displays the alphabetical representation of that number. But I'm hoping that I can miss that due to the complexity – Chris Feb 14 '11 at 10:26
  • possible duplicate of [C# Convert Integers into Written Numbers](http://stackoverflow.com/questions/3213/c-convert-integers-into-written-numbers) – AakashM Feb 16 '11 at 16:39

0 Answers0