From:

Date:

January 25, 2005 09:05Subject:

[PATCH] BigInt mbi_rand.t failingsMessage ID:

200501251806.59782@bloodgate.comdiff -ruN blead/lib/Math/BigInt/Calc.pm blead.patch/lib/Math/BigInt/Calc.pm --- blead/lib/Math/BigInt/Calc.pm 2005-01-04 10:06:32.000000000 +0100 +++ blead.patch/lib/Math/BigInt/Calc.pm 2005-01-25 17:59:33.000000000 +0100 @@ -6,7 +6,7 @@ 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 @@ # 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 @@ # 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; }Thread Next

**[PATCH] BigInt mbi_rand.t failings**by Tels- Re: [PATCH] BigInt mbi_rand.t failings (solved now) by Tels
- Re: [PATCH] BigInt mbi_rand.t failings (solved now) by Rafael Garcia-Suarez
- Re: [PATCH] BigInt mbi_rand.t failings (solved now) by Ed Allen Smith
- Re: [PATCH] BigInt mbi_rand.t failings by Rafael Garcia-Suarez
- Re: [PATCH] BigInt mbi_rand.t failings by Steve Hay
- Re: [PATCH] BigInt mbi_rand.t failings by Tels
- Re: [PATCH] BigInt mbi_rand.t failings by Tels
- Re: [PATCH] BigInt mbi_rand.t failings by Steve Hay
- Re: [PATCH] BigInt mbi_rand.t failings by Tels
- Re: [PATCH] BigInt mbi_rand.t failings by Steve Hay

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About