From: Robert Klemme Date: 2009-04-14T16:43:05+09:00 Subject: Re: a few thoughts for ruby... Please do not top post. 2009/4/14 Julian Leviston : > Why aren't they? What do you mean by this out of interest? 09:41:50 ~$ ruby19 x.rb Float 0.00000000010000000827 BigDecimal 0.00000000010000000000 Float 0.00000000000000000827 BigDecimal 0.00000000000000000000 false true 09:41:52 ~$ cat x.rb require 'bigdecimal' f = (1.0 + 1.0e-10) - 1.0 bd = (BigDecimal.new("1.0") + BigDecimal.new("1.0e-10")) - BigDecimal.new("1.0") printf "%-10s %30.20f\n", f.class, f printf "%-10s %30.20f\n", bd.class, bd f -= 1.0e-10 bd -= BigDecimal.new "1.0e-10" printf "%-10s %30.20f\n", f.class, f printf "%-10s %30.20f\n", bd.class, bd puts f == 0.0, bd == 0.0 09:41:57 ~$ > On 11/04/2009, at 6:45 PM, Robert Klemme wrote: > >> Seems reasonable at first sight but the absence might have a reason. For >> example, by making the conversion to String explicit it is more obvious that >> float and BigDecimal are not really compatible. Cheers robert -- remember.guy do |as, often| as.you_can - without end