Hacker News new | ask | show | jobs
by ascar 1477 days ago
Your points are factually correct, but in practice not a big concern, if your floating point value is much more precise than necessary for the numbers used.

E.g. if you use doubles for the range of 32bit integers even adding 1.0 2 billion times to 2 billion still ends up at 4 billion. Even adding 1.0 20 billion times to 20 billion ends up at 40 billion. Now adding 0.1 20 billion times to 2 billion ends up 1908 short on my CPU, i.e. about 19080 absorptions/rounding errors occured. You need some serious differences and amount of operations to actually trigger errors.

1 comments

You're talking about the best case, but we need to take the reasonable worst cases into account, where x + y nearly cancel etc.