4 ms·
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
by techiferous 17y ago
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