3 ms·
IMHO, the right thing to do would be to forbid the usage of == for decimals values. 1.0 == 0.9 -> Throw err 1.0 > 0.9 -> true In most case, you don't want
by d0m 14y ago
IMHO, the right thing to do would be to forbid the usage of == for decimals values.
1.0 == 0.9 -> Throw err
1.0 > 0.9 -> true
In most case, you don't want to use == on double because it 's very dangerous... it's way better to use (0.3 - 0.3000001) < 0.001 or something similar. So, by forbidding the == on doubles, you force the programmer to use a safer way. In the same time, it's a clean hack around this decimal issue. As a bonus, a programmer who doesn't know binaries arithmetic might get curious on why == isn't implemented on double and read on it.