devxlogo

Display Small Decimals Using VBScript

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 "

" & 5 / 50025 * 100 & "%"Response.Write "

" & FormatPercent(5 / 50025, 4) '4 digits after decimal pointResponse.Write "

" & FormatNumber(5 / 50025, 4) '4 digits after decimal point

will produce:

 9.99500249875063E-03% 0.0100% 0.0001 
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist