On Tue, May 5, 2009 at 6:02 AM, David Cantrell <[email protected]>wrote:

> 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.
>

Perhaps I should stringify and then re-numberify the value inside round()
instead?

Reply via email to