|Subject:||batan2(1,0) not following global accuracy()|
|Date:||Wed, 01 May 2013 06:50:23 +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->accuracy(100) has been set then batan2() of Y=1,X=0 only gives 40 decimal places of accuracy, not the requested 100. Eg. the program atan2.pl below prints 1.570796326794896619231321691639751442098000000000000000000000000000000000000000000000000000000000000 whereas I expected the trailing 0s to be some non-zero value. If $x is some small non-zero value, such as 1e-10 then the desired full 100 decimals are returned. In the code I wonder if the special cases for X=0 and Y=0 giving pi/2 etc could look also at the accuracy() and/or precision setting on $y or $x or global or whatever, so as to ensure the result in those cases is the same accuracy as the general case.
use strict; use Math::BigFloat; Math::BigFloat->accuracy(100); my $y = Math::BigFloat->new(1); my $x = Math::BigFloat->new(0); $y->batan2($x); print "$y\n";