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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is there a round up in ASP

Status
Not open for further replies.

andycape

Programmer
Aug 22, 2003
177
ZA
is there a way to round up a value in ASP?

ie : "1.9" or "1.2" will both become "2"


thanx

 
try this:
var = 1.2
response.write int( var + 1) & &quot;<br>&quot;
var = 1.9
response.write int( var + 1)


see:

notice the remark on negative numbers!


hth,
Foxbox
ttmug.gif
 
Hello all,

Or rather
Code:
function Roundup(v)
    if int(v)=v then Roundup=v else Roundup=int(v+1)
end function
It's up to you to decide the behavior for v being negative.

regards - tsuji
 
If you use the Round function you can keep the function clean while also accounting for negative numbers:
Code:
Function RoundUp(num)
   If Round(num) < num Then RoundUp = Round(num+.5) Else RoundUp = Round(num)
End Function

Basically this should cover everything negative and positive without any extra work.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top