From: Tels Date: Tue, 25 Jan 2005 18:06:58 +0000 (+0100) Subject: BigInt mbi_rand.t failings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da21930332ec1997612ca0fbcfe4ac176237c0e5;p=p5sagit%2Fp5-mst-13.2.git BigInt mbi_rand.t failings Message-Id: <200501251806.59782@bloodgate.com> p4raw-id: //depot/perl@23882 --- diff --git a/lib/Math/BigInt/Calc.pm b/lib/Math/BigInt/Calc.pm index 41183f5..2fafc51 100644 --- a/lib/Math/BigInt/Calc.pm +++ b/lib/Math/BigInt/Calc.pm @@ -6,7 +6,7 @@ use strict; use vars qw/$VERSION/; -$VERSION = '0.44'; +$VERSION = '0.45'; # Package to store unsigned big integers in decimal and do math with them @@ -578,7 +578,11 @@ sub _div_use_mul # between 1 and MAX_VAL (e.g. one element) and rem is not wanted. if (!wantarray) { - $x->[0] = int($x->[-1] / $yorg->[-1]); + # fit's into one Perl scalar, so result can be computed directly + # cannot use int() here, because it rounds wrongly on some systems + #$x->[0] = int($x->[-1] / $yorg->[-1]); + # round to 8 digits, then truncate result to integer + $x->[0] = int ( sprintf ("%.8f", $x->[-1] / $yorg->[-1]) ); splice(@$x,1); # keep single element return $x; } @@ -775,7 +779,11 @@ sub _div_use_div # between 1 and MAX_VAL (e.g. one element) and rem is not wanted. if (!wantarray) { - $x->[0] = int($x->[-1] / $yorg->[-1]); + # fit's into one Perl scalar, so result can be computed directly + # cannot use int() here, because it rounds wrongly on some systems + #$x->[0] = int($x->[-1] / $yorg->[-1]); + # round to 8 digits, then truncate result to integer + $x->[0] = int ( sprintf ("%.8f", $x->[-1] / $yorg->[-1]) ); splice(@$x,1); # keep single element return $x; }