# quick easy question

• 01-25-2008
Yarin
quick easy question
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?
• 01-25-2008
tabstop
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.
• 01-25-2008
laserlight
Quote:

I know floats are not percise, as in, they are never EXACTELY what you set them.
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).

Quote:

1.0 might be somthing like 1.000000001206 for example.
I do not think so, since 1.0 can be accurately represented in floating point.

Quote:

But are doubles percise, or do they do this haywire thing too?
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.
• 01-25-2008
Yarin
Thanks. That is what I needed to know.