From: matz@... (Yukihiro Matsumoto) Date: 2003-04-18T00:22:02+09:00 Subject: Re: Roundoff problem with Float and Marshal Hi, In message "Re: Roundoff problem with Float and Marshal" on 03/04/17, Rudi Cilibrasi writes: |The DBL_DIG patch makes the problem less common, but does not solve it; | |[[1,2,3,4], [81, 2, 118, 3146]].each { |w,x,y,z| |a = (x.to_f + y.to_f / z.to_f) * Math.exp(w.to_f / (x.to_f + y.to_f / z.to_f)) |ma = Marshal.dump(a) |b = Marshal.load(ma) |if a == b | puts "Everything is working fine for #{a}" |else | puts "PROBLEM: a is #{a}, b is #{b}, and ma is #{ma.dump}" |end |} | |Produces | |Everything is working fine for 3.95601527633861 |PROBLEM: a is 3.7517675036461267e+17, b is 3.7517675036461261e+17, |and ma is "\004\010f\e3.7517675036461267e+17" This is caused by bad implementation of strtod that Ruby 1.8 uses (in util.c). I will seek for the better one. matz.