3 ms·
You'd find plenty of unfriendly inequalities just like yours if you made the exponent decimal. e.g 1/3 + 1/3 + 1/3 != 1. The fundamental issue remains, which is
by topaz0 4y ago
You'd find plenty of unfriendly inequalities just like yours if you made the exponent decimal. e.g 1/3 + 1/3 + 1/3 != 1. The fundamental issue remains, which is that some rationals don't have exact representations in the (finite) floats, so there is some roundoff error. Sure, using decimals means that if you're only working with decimal literals and addition and subtraction and possibly multiplication you usually won't have any roundoff, but how often are you doing something that matters that won't add roundoff some other way?
Someone here said recently: It is rarely a good idea to compare finite representations of real numbers for equality. I am inclined to agree.