From: Zsban Ambrus Date: 2004-05-15T03:54:51+09:00 Subject: Re: Major Addition Bug? On Fri, May 14, 2004 at 07:01:23AM +0900, Jeff Mitchell wrote: > > This all suggests: > > class FuzzyFloat > def initialize(value, epsilon) > @value = value > @epsilon = epsilon > end > > attr_reader :value, :epsilon > > def *(other) > FuzzyFloat.new(@value*other.value, @epsilon + other.epsilon) > end > > def ==(other) > distance = abs(@value - other.value) > (distance < @radius) and (distance < other.radius) > end > > # ... > end > > however there is a general problem of epsilon approaching the > granularity of Float itself, i.e. the error of the error. The Float > version of Planck's constant confounds our measurements :) But > FuzzyFloat may still have some use for sufficiently large epsilon. > Why not do interval arithmetics? Of course, you can't implement that in pure ruby, only as a C addition, as you'll have to do arithmetic in different rounding modes. ambrus