Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

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

"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
Posted
  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()

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...