re: Float>>equals: changed in 4.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

re: Float>>equals: changed in 4.0

ben meyer
Just wondering why this method was changed from 3.0?  New version breaks one
of my tests for equality.  I imported the old method and it works.

Anyway, the new product feels nice and solid.

--Ben Meyer


Reply | Threaded
Open this post in threaded view
|

Re: Float>>equals: changed in 4.0

Blair McGlashan
Ben

You wrote in message news:93fmpe$a0hjh$[hidden email]...
> Just wondering why this method was changed from 3.0?  New version breaks
one
> of my tests for equality.  I imported the old method and it works.

The old version only worked for "smaller" Floats - those with large
exponents which were theoretically equal within precision limits were not
regarded as such because the allowable difference was not scaled to match
the scale of the numbers. The new version should be correct, although it is
slower. Please post the example you are having a problem with, and then we
can assess whether it is the #equals: method or your test that is at fault.

>
> Anyway, the new product feels nice and solid.

Thank you.

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Float>>equals: changed in 4.0

ben meyer
Hello,

> The old version only worked for "smaller" Floats - those with large
> exponents which were theoretically equal within precision limits were not
> regarded as such because the allowable difference was not scaled to match
> the scale of the numbers. The new version should be correct, although it
is
> slower. Please post the example you are having a problem with, and then we
> can assess whether it is the #equals: method or your test that is at
fault.


With 4.0 PL1 evaluating each of the following gives me 'false'
-2.0e-4 equals: 0.0
-2.22044604925031e-016 equals: 0.0
-2.0e-30 equals: 0.0

With 3.06 PL5 evaluating the first gives 'false', and the last two gives me
'true'

This is with SignificantDifference 1.0e-9.

I would have thought 3.06 PL5 results were correct.  I copied 3.06 version
into 4.00 and it works for now.

Thank you,

Ben Meyer


Reply | Threaded
Open this post in threaded view
|

Re: Float>>equals: changed in 4.0

Blair McGlashan
Ben

"ben meyer" <[hidden email]> wrote in message
news:93klt2$b0h9h$[hidden email]...
> ...
> With 4.0 PL1 evaluating each of the following gives me 'false'
> -2.0e-4 equals: 0.0
> -2.22044604925031e-016 equals: 0.0
> -2.0e-30 equals: 0.0

Hmmm. Well its clearly not working around zero! I think reverting to the
simpler 3.06 definition, as you have done, is probably the best choice for
now, althoug the latter does not work correctly for examples such as the
last of:

1.0e308 equals: 1.000000001e308        "should be false"
1.0e308 equals: 1.0000000001e308       "should be true"

If one interprets the "SignificantDifference" as indicating the number of
significant figures, on the basis that there is no point using a simplistic
comparison between two such large numbers for a difference of 1.0e-9, as
that is way outside the precision of the representation.

Thanks

Blair