|Subject:||BigFloat bpi() NaN when global precision() set|
|Date:||Wed, 01 May 2013 06:00:24 +1000|
|To:||bug-Math-BigInt [...] rt.cpan.org|
|From:||Kevin Ryde <user42 [...] zip.com.au>|
In Math::BigFloat 1.997 and recent debian i386 perl 5.14.3, if a global Math::BigFloat->precision() has been set then bpi() returns NaN. Eg. the program foo.pl below prints "NaN". foo.pl asks for precision -100 to have 100 decimal places and I hoped bpi(5) asking for pi to 5 places still would work in that case. Nosing around the code I see bpi() calls bdiv() with a specified accuracy, and it seems the usual _find_round_parameters() rejects a simultaneous accuracy and precision in force. I suppose if the precision() is less than the bpi number of digits then take the lesser of the two, the same as results when an accuracy() is in force and you ask bpi for more digits than that accuracy.
use strict; use Math::BigFloat; Math::BigFloat->precision(-100); my $pi = Math::BigFloat->bpi(5); print "$pi\n";