I know floats are not percise, as in, they are never EXACTELY what you set them. (1.0 might be somthing like 1.000000001206 for example.)
But are doubles percise, or do they do this haywire thing too?
This is a discussion on quick easy question within the C++ Programming forums, part of the General Programming Boards category; I know floats are not percise, as in, they are never EXACTELY what you set them. (1.0 might be somthing ...
I know floats are not percise, as in, they are never EXACTELY what you set them. (1.0 might be somthing like 1.000000001206 for example.)
But are doubles percise, or do they do this haywire thing too?
I don't see why people think Chuck Norris is so awesome. If he was really as great as they say, he would be over here slamming my head into the keybsk;lah;flksalfksdnlcslcnsldk;acklsd;glfbaskfl
/* When I wrote this, only God and I understood what I was doing... Now, God only knows */
To some extent this is implementation defined, but if we're thinking about an IEEE float/double, then any number that only requires 23 bits to represent (with a floating binary point) can be represented exactly (so 1.0, 1.5, 1.25, 1.125, etc. can all be represented exactly, but 1.1 cannot). With doubles, it's 52 bits. So the same problem is there, it's just that the errors are farther down the line.
Edit to add: Actually I forgot about the implicit one in front of the binary point -- so any number that's representable with 24 bits/53 bits works.
Last edited by tabstop; 01-25-2008 at 12:57 PM.
I believe "precision" is usually used to refer to how many digits/bits can be used to represent a number (or to what decimal place some quantity can be measured), whereas "accuracy" considers how close to the actual value is its representation (or its measured value).I know floats are not percise, as in, they are never EXACTELY what you set them.
I do not think so, since 1.0 can be accurately represented in floating point.1.0 might be somthing like 1.000000001206 for example.
The problem with floating point inaccuracy is with any floating point scheme, regardless of the amount of precision. Take (1.0/3.0) for example.But are doubles percise, or do they do this haywire thing too?
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
Thanks. That is what I needed to know.
I don't see why people think Chuck Norris is so awesome. If he was really as great as they say, he would be over here slamming my head into the keybsk;lah;flksalfksdnlcslcnsldk;acklsd;glfbaskfl
/* When I wrote this, only God and I understood what I was doing... Now, God only knows */