News for hackers. Stuff that matters.
Re:WTFJS? by techiferous on Friday February 12, 2010 @10:25PM (#1122467)
In Ruby:

0.1 + 0.2 == 0.3 => false

According to "The Ruby Programming Language", all languages that use IEEE-754 floating-point numbers have this problem.

In Ruby you can get around this by using BigDecimal.

>> require 'bigdecimal'

=> true

>> require 'bigdecimal/util'

=> true

>> 0.1.to_d + 0.2.to_d == 0.3.to_d

=> true

There are no comments on this comment yet.