|
-
Feb 28th, 2007, 05:45 PM
#1
Thread Starter
Hyperactive Member
rounding to a specific place?
when I have cin >> dprice; get a double value and I type in 8.88, it gets immediately stored as 8.8800000000000008. Now the real questions about this would be like why does it do that, why don't they fix that, and why do people still use C++ when it does stuff like that?
But my question for the time being is, how can I round that value off to one less place to get rid of the extra value that gets tacked on? Math.h's ceil rounds it up to 9 and floor drops it to 8 and it doesn't seem to take any parameters for the amount of decimal places I want so is there another common library that has a round function or any other way to fix it other than rounding?
oh and btw, MSND says the C++ version of math.h has a round function that does just that but the compiler says it doesn't.
Last edited by Desolator144; Feb 28th, 2007 at 05:51 PM.
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|