Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to get rid of decimals (Single)

Status
Not open for further replies.

arneweise77

Programmer
Apr 25, 2002
46
SE
Hi everyone!

I believe this is a simple problem, but I need a simple solution as well, which I can´t figure out.

I have this single decimal variable let´s say 3,45555555 returned to me from a function, but all I need is 3,46 or something close to that.

Can someone help med solve this, the best and easiest way possible?

Thanx in advance!

Arne
 
Try using the FormatNumber function.

Response.write(FormatNumber(num1,2))

Where num1 is the variable containing the number you wish to format and 2 is the number of digits after the decimal that you wish to display.

Here is some info from DevGuru on FormatNumber (watch for wrap on the link):
 
use the round function: round(3.45555555,2) = 3.46

if you have a comma instead of a decimal point then do a replace on , to . also remember to convert from string to numerical type(if it is in this form)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top