logoalt Hacker News

erutoday at 4:07 AM1 replyview on HN

Huh, what? Floating point numbers have a standard, you know. They aren't non-deterministic YOLO numbers.

By default, the compiler has to stick to what the standard requires, and can't just say add arbitrary imprecision.

Your epsilon is what you get when you try to analyse floating point numbers as approximations of real numbers. But they also have an independent life as bit patterns, and the compiler can't just willy-nilly muck around with these bit patterns.


Replies

nomeltoday at 4:15 AM

Please look at the link where context is clear here. Floating point has limited precision and the complete inability to exactly represent some numbers.

Example, this equality check is false:

0.1 + 0.2 == 0.3

Because the last bits of a floating point number, after any practical chain of operations, is practically random, do to errors from limited precision. Yes you can always know what the result will exactly be for any operation, if you know the exact number and operations used. Good luck with something like sin/cos though, where implementations can vary wildly depending on the platform/library.

show 1 reply