Here Is an Easy One I mean it this time

rifter1818

Well-known member
Joined
Sep 11, 2003
Messages
255
Location
A cold dark place
Is there a function for rounding to whole numbers that allways rounds up on excactly .5 Cint() and cbyte() both round to the nearest even number in the case of .5.....
 
If you check out the help in MSDN, youll see that Math.Round is supposed to round the way it does. It might not make sense to "most" of us, but it now matches the standards. Go figure.

Any easy solution is to offset your number and use Floor. If you want to round to the nearest whole number, use:
Math.Floor(d + 0.5)

For 1 decimal place:
Math.Floor(d + 0.05)

For 2 decimals:
Math.Floor(d + 0.005)

You get the idea.

-Nerseus
 
Originally posted by Nerseus
If you check out the help in MSDN, youll see that Math.Round is supposed to round the way it does. It might not make sense to "most" of us, but it now matches the standards. Go figure.

Any easy solution is to offset your number and use Floor. If you want to round to the nearest whole number, use:
Math.Floor(d + 0.5)

For 1 decimal place:
Math.Floor(d + 0.05)

For 2 decimals:
Math.Floor(d + 0.005)

You get the idea.

-Nerseus
or if you want to Round up to the nearest whole number its math.ceiling()
 
Floor and cieling

That should do it,.. not the way i wanted too, Im well aware of the standards of rounding but i would have thought theyed have left at least one function the "Wrong" or as i like to see it old way.... Thanks for your help guys (and gals if appropriate). Just 5 other proplems (posts) to go and i should be good. for now
 


Write your reply...
Back
Top