Numerical problems of mswin32 Ruby

Javier Goizueta wrote:

If you try the following in mswin32-1.8.1:

require ‘bigdecimal’
puts (BigDecimal(‘355’)/BigDecimal(‘226’)).to_f - (355.0/226.0)

This thread, http://tinyurl.com/2x34f, leads me to believe that the
proper way to write this is:

puts (BigDecimal(‘355’).to_f/BigDecimal(‘226’).to_f) - (355.0/226.0)

This returns 0.0. If not “proper”, it’s at least a “workaround”. :slight_smile:

Regards,

Dan