rifter1818 Posted February 18, 2004 Posted February 18, 2004 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..... Quote
bungpeng Posted February 19, 2004 Posted February 19, 2004 Did you try Round() function before? Quote
rifter1818 Posted February 19, 2004 Author Posted February 19, 2004 Nope cant say that i have. Same thing though rounds to nearest even number. Quote
*Experts* Nerseus Posted February 19, 2004 *Experts* Posted February 19, 2004 If you check out the help in MSDN, you'll 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 Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
AFterlife Posted February 19, 2004 Posted February 19, 2004 Nerseus said: If you check out the help in MSDN, you'll 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() Quote
rifter1818 Posted February 19, 2004 Author Posted February 19, 2004 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.