ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Format library

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
95 active users
727 visitors today
685 pages today
(only part of today)
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
ASPRSS
ShawThing

Now open source with SourceForge!

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

11.00
1.11.10
1.231.23
1.2345671.23
1.2351.24
1.2361.24

Featured sponsor
My favorite resources

Selling products online - read how James does it now


CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?


Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!