3 ms·
You can't model 1.0 correctly but it will be something like 1.000006667. If you add enough of these numbers you will be off.
by maxxxxx 8y ago
You can't model 1.0 correctly but it will be something like 1.000006667. If you add enough of these numbers you will be off.
- recursive 8y agoYour details are off. 1.0 is precisely representable in double precision floating point with no error.
- maxxxxx 8y agoSorry, picked the wrong number. But I think the general idea is correct.
- aaaaaaaaaab 8y agoIntegers can be represented exactly in IEEE754.
- maxxxxx 8y agoHow about 2.1? According to this https://www.h-schmidt.net/FloatConverter/IEEE754.html https://www.h-schmidt.net/FloatConverter/IEEE754.html 2.1 will be represented as 2.099999904632568359375
- noselasd 8y agowell, 2.1 isn't an integer.
- noselasd 8y agoNot all of them, e.g. 9007199254740993 can't be represented in a double precision format (what javascript uses) For single precision floats you start having issues representing integers as low as 16777217
- aaaaaaaaaab 8y agoSure, you can’t represent Graham’s number either... I know you knew what I meant.
- noselasd 8y agoNo not really. You have to define the bounds you were talking about. People believing that a float type can represent all integers that the int type in their language can represent is not exactly uncommon.