develooper Front page | perl.perl5.porters | Postings from July 2000

Questions about Math::BigFloat

From:
John Peacock
Date:
July 28, 2000 09:59
Subject:
Questions about Math::BigFloat
Message ID:
3981BB73.6EEB124B@UnivPress.com
I have recently rewritten a module of mine (Math::FixedPrecision) to use 
Math::BigFloat and have found some problems with it.  There is no e-mail
address listed for the author, Mark Biggar, so I am directing the query
here.  Is anyone working on a replacement to this module (as the POD
would imply) or should I submit a patch to fix what I have found.

It would appear that the even/odd rounding methods will always round in
the opposite direction following IEEE 754 rules.  I checked the test 
file from the Perl distribution and see errors running with my now
corrected version (where I think there should be none).  For example:

	use Math::BigFloat;
	$num = new Math::BigFloat "5.25";

	#round up only if preceeding digit is even
	$Math::BigFloat::rnd_mode = 'even';
	print 0+$num->ffround(-1), "\n"; 
	#prints 5.2, s.b. 5.3

	#round up only if preceeding digit is odd
	$Math::BigFloat::rnd_mode = 'odd';
	print 0+$num->ffround(-1), "\n"; 
	#prints 5.3, s.b. 5.2

The compare sub fcmp does not work when the two term's exponents are 
different (although that seems to have been the goal).  I have also
corrected this as well.

I haven't fixed up t/bigfltpm.t, but I can do that before I submit
patches.

Thanks

John Peacock



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About