Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic, Web
Expertise: All
Jul 22, 1999

Display Small Decimals Using VBScript

It is common to have online survey results posted via an ASP page. While for the most part it will work fine, you have to be careful when your results contain small irrational numbers. For small irrational numbers, ASP automatically returns the number in scientific notation. To avoid this result, use either the FormatPercent or the FormatNumber function. Conveniently, the FormatPercent function will multiply your result by 100. For example, this code:

 
Response.Write "<P>" & 5 / 50025 * 100 & "%"
Response.Write "<P>" & FormatPercent(5 / 50025, 4) '4 digits after decimal point
Response.Write "<P>" & FormatNumber(5 / 50025, 4) '4 digits after decimal point

will produce:

 
9.99500249875063E-03% 
0.0100% 
0.0001 
William Wen
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap