summaryrefslogtreecommitdiff
path: root/lib/Math
diff options
context:
space:
mode:
authorTels <nospam-abuse@bloodgate.com>2005-01-25 19:06:58 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-01-25 16:53:08 +0000
commitda21930332ec1997612ca0fbcfe4ac176237c0e5 (patch)
tree0a1fcfca2eb471c4a80cd30f1e5bfc2797a56716 /lib/Math
parent6832267f461983b0afff776101f8a2b10d128d79 (diff)
downloadperl-da21930332ec1997612ca0fbcfe4ac176237c0e5.tar.gz
BigInt mbi_rand.t failings
Message-Id: <200501251806.59782@bloodgate.com> p4raw-id: //depot/perl@23882
Diffstat (limited to 'lib/Math')
-rw-r--r--lib/Math/BigInt/Calc.pm14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Math/BigInt/Calc.pm b/lib/Math/BigInt/Calc.pm
index 41183f5e7c..2fafc51c83 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;
}