-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'use bigrat' anywhere makes Math::BigRat::as_float return wrong results #15256
Comments
From @jimavThis is a bug report for perl from jim.avera@gmail.com, Hello, The as_float() method on Math::BigRat objects seems to return wrong I'm guessing there is a conversion-code bug in some case which is only In any case, it doesn't seem right that "use bigrat" has global -Jim #!/usr/bin/perl my $x = Math::BigRat->new("314/100"); print "x = ", Dumper($x), "\n"; exit 0; { use bigrat } # commenting this out makes bug go away Flags: Site configuration information for perl 5.20.2: Configured by Debian Project at Tue Mar 1 16:51:39 UTC 2016. Summary of my perl5 (revision 5 version 20 subversion 2) configuration: Locally applied patches: @INC for perl 5.20.2: Environment for perl 5.20.2: |
From @jimavOn Tue Mar 29 17:55:34 2016, jim.avera@gmail.com wrote:
The Math::BigRat man page says as_float() takes an optional accuracy argument with "as_float() $x = Math::BigRat->new('2/3'); Returns a copy of the object as BigFloat, preserving the accuracy as Even if an accuracy is given explicitly, it seems to be ignored if "use bigrat" is ever compiled. Probably related: The following loops with infinite recursion: $ perl -wE 'use Math::BigRat; $x=Math::BigRat->new("2/3"); $y=$x->as_float(5); say $y-$x; use bigrat' (but works fine if the trailing 'use bigrat' is removed) |
From @tonycozOn Tue Mar 29 17:55:34 2016, jim.avera@gmail.com wrote:
bignum and Math::Big* are now maintained on CPAN, not as part of the perl core. That said, this appears to be caused by: Math::BigFloat->import(upgrade => 'Math::BigRat', ':constant'); in bigrat::import(), if that's commented out the expected value is returned. Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @pjacklamI have forwarded this issue to CPAN RT, and I will look into it. The URL https://rt.cpan.org/Public/Bug/Display.html?id=113588 Peter 2016-03-30 2:55 GMT+02:00 via RT <perlbug-followup@perl.org>:
|
@iabyn - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#127802 (status was 'rejected')
Searchable as RT127802$
The text was updated successfully, but these errors were encountered: