Skip Menu |

This queue is for tickets about the Math-Round CPAN distribution.

Report information
The Basics
Id: 110436
Status: stalled
Priority: 0/
Queue: Math-Round

People
Owner: Nobody in particular
Requestors: EDAVIS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.07
Fixed in: (no value)



Subject: nearest() gives NaN for input and rounding that are not NaN - interaction with Math::BigRat
Hi, I have used the module Math::BigRat, which is a core Perl module since perl 5.8.0, to store a rational number and then convert it to floating point. But then Math::Round::nearest behaves oddly with the resulting scalar. use Math::BigRat; use Math::Round qw(nearest); my $x = new Math::BigRat(1); $x = $x->as_float; print $x, "\n"; print nearest(0.0001, $x), "\n"; print nearest(0.00001, $x), "\n"; For me this prints 1 0 NaN So we have what looks like an ordinary number 1, which is rounded correctly when you give a target rounding of 0.0001, but strangely gives NaN if the target is 0.00001. This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-thread-multi (with 14 registered patches, see perl -V for more detail) (Perl packaged by Fedora 23 x86_64)
Sorry, it appears that as_float() returns a Math::BigFloat object not an ordinary scalar. It's still weird, but probably the bug is with Math::BigFloat. Will update here when I get to the bottom of it.
See https://rt.perl.org/Public/Bug/Display.html?id=126960 I think that when the bug in Math::BigFloat is fixed then this will be fixed too.