I had to display some floating point numbers to 2 decimal places yesterday. (VBScript guys, please cover your eyes and ears, I'm gonna whisper this)JavaScript doesn't provide a method for this I couldn't believe it either. But being a die-hard C programmer I like challenges! I only had to deal with positive numbers in the application I was writing, so take heed. Negative numbers are not supported! Here are some examples of numbers, both raw and formatted to demonstrate. Note how they all have 2 decimal places and are rounded up to the nearest penny. Raw
| Formatted
| 1 | 1.00 | 1.1 | 1.10 | 1.23 | 1.23 | 1.234567 | 1.23 | 1.235 | 1.24 | 1.236 | 1.24 |
|