On Sun, May 03, 2009 at 12:23:27PM -0700, Bill Ward wrote:
> On Sun, May 3, 2009 at 12:18 PM, Andy Armstrong <[email protected]> wrote:
> > On 3 May 2009, at 20:07, Bill Ward wrote:
> >> For my module Number::Format I am getting a strange result from cpan
> >> testers that I can't replicate.  See this error report...
> >> http://www.nntp.perl.org/group/perl.cpan.testers/2009/03/msg3560533.html
> >> [...]Since it's using '==' it shouldn't be possible to get those errors,
> >> right?  Anyone have any thoughts?
> > Yeah, that's floating point. There can be a difference between the two
> > values that's too small to display but big enough to make them non-equal.
> > '==' is /always/ risky with FP values.
> > You should instead check for the value being within an acceptable range.
> Do you think I should change it to use eq in the test?

It may work, or it may not.  If it "works" - in the sense of making the
test failure go away - then I would expect it to bite someone later when
they just happen to hit upon a number where the floating point rounding
error goes the other way.

Check that it's in an acceptable range.

-- 
David Cantrell | Enforcer, South London Linguistic Massive

Aluminum makes a nice hat.  
All paranoids will tell you that.
But what most do not know     
Is reflections will show    
On the CIA's evil landsat.

Reply via email to