It has been a while since there has been a good round of golf, so I decided to post one. I couldn't come up with a nice interesting math brain-teaser, so I'll post this one.
The Rules- Write a sub that takes a number as an argument and returns it in the standard monetary format -- with comma's and to two decimal places
Expected Input-Output
- Input: 3
- Output: 3.00
- Input: 1000
- Output: 1,000.00
- Input: 12345678
- Output: 12,345,678.00
- Input: 4444444.11
- Output: 4,444,444.11
- Input: 98765.343
- Output: 98,765.34
- Input: 111.229
- Output: 111.23
My Swing (83 chars)
|
Enoch
(update: Changed "integer" to "number". Integers don't have decimals. Thanks to xylus for pointing out my err.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (Golf) Formatting Integer To Money
by Abigail-II (Bishop) on Aug 29, 2002 at 17:04 UTC | |
by dpuu (Chaplain) on Aug 29, 2002 at 17:41 UTC | |
by thelenm (Vicar) on Aug 29, 2002 at 18:45 UTC | |
by larryk (Friar) on Aug 29, 2002 at 20:55 UTC | |
by xylus (Pilgrim) on Aug 29, 2002 at 17:36 UTC | |
by enoch (Chaplain) on Aug 29, 2002 at 17:41 UTC | |
Re: (Golf) Formatting NumberTo Money
by Anonymous Monk on Aug 29, 2002 at 18:36 UTC | |
Re: (Golf) Formatting Integer To Money
by Aristotle (Chancellor) on Aug 29, 2002 at 17:53 UTC | |
Re: (Golf) Formatting NumberTo Money
by Django (Pilgrim) on Aug 29, 2002 at 19:06 UTC |
Back to
Meditations