▲ | calibas 2 days ago | |||||||
> They are not exact It's not exactly a myth, as the article mentions, they're only exact for certain ranges of values. > NaN and INF are indication of an error This is somewhat semantic, but dividing by zero typically does create a hardware exception. However, it's all handled behind the scenes, and you get "Inf" as the result. You can make it so dividing by zero is explicitly an error, see the "ftrapping-math" flag. | ||||||||
▲ | GuB-42 2 days ago | parent | next [-] | |||||||
I think the myth about exactness is that you can't use strict equality with floating point numbers because they are somehow fuzzy. They are not. Some operations involve rounding, notably conversion from decimal, but the (rounded) result is an exact number that can be stored and recovered without loss of precision and equality will work as expected. Converting from floating point binary to decimal is exact though, given enough digits (can be >1000 for very small or very large numbers). | ||||||||
| ||||||||
▲ | 2 days ago | parent | prev [-] | |||||||
[deleted] |