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 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?
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 01: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?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)