approxEqual() has fooled me for a long time...

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Thu Oct 21 00:51:06 PDT 2010


On Wed, 20 Oct 2010 23:19:11 -0500, Andrei Alexandrescu wrote:

> So here's a plan of attack:
> 
> 1. Keep feqrel. Clearly it's a useful primitive.
> 
> 2. Find a more intuitive interface for feqrel, i.e. using decimal digits
> for precision etc. The definition in std.math: "the number of mantissa
> bits which are equal in x and y" loses 90% of the readership at the word
> "mantissa". You want something intuitive that people can immediately
> picture.
> 
> 3. Define a good name for that
> 
> 4. Decide on keeping or deprecating approxEqual depending on the
> adoption of that new function.


First attempt, using Walter's name suggestion, matchDigits():

  http://www.dsource.org/projects/scid/browser/scid/util.d

Too simplistic?  Comments are welcome.

-Lars


More information about the Digitalmars-d mailing list