3 ms·
A related fact: all functions are defined on closed sets. You cannot "tell" whether a number is in a set or is a limit point of a set. Since all functions are c
by edflsafoiewq 7y ago
A related fact: all functions are defined on closed sets. You cannot "tell" whether a number is in a set or is a limit point of a set. Since all functions are continuous, they work at limit points too.
As a "practical" consequence: the common design of a random() function returning values in [0, 1) is wrong. Any function you write cannot "tell" whether it got a 1 or not.
These are still very good guidelines even for floating-point code, as long as you, like most everyone else, treat floats as a blackbox abstraction for "real" real numbers.
- poizan42 7y agoWell, random() functions that are normally used are defined on the [0, 1) interval of 32-bit or 64-bit IEEE 754 floating point numbers, for which it is very much computable to determine whether they are exactly 1 (there's nothing "real number" about them though, they all belong to a small finite subset of the rations). Of course that isn't really an open interval in the topological sense either.
- edflsafoiewq 7y agoBut that's why it's often a bad idea to test exact equality of floats: the equality test isn't continuous. In fact, for float computations it's usually even more important to use continuous (ie. error tolerant) functions, since floating-point operations can introduce errors.
- saagarjha 7y agoComparing IEEE 754 floating point number is well defined and computable because the domain is discontinuous. It’d be stupid to use anything else…
- deleted 7y ago[deleted]