News for hackers. Stuff that matters.
Re:0.3 - 0.2 == 0.2 - 0.1 is falsy. Which language gets this... by d0m on Thursday October 04, 2012 @12:07PM (#4612968)
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.

There are no comments on this comment yet.