Skip Menu |

This queue is for tickets about the Math-BigInt CPAN distribution.

Report information
The Basics
Id: 530
Status: resolved
Priority: 0/
Queue: Math-BigInt

People
Owner: TELS [...] cpan.org
Requestors: bernard.plessier [...] st.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.56
Fixed in: (no value)



Subject: bdiv and bmode broken!!!
Perl version 5.005 (sun4-solaris) uname -a : SunOS censored 5.7 Generic_106541-16 sun4u sparc SUNW,Ultra-5_10 Code example: ------------------------------------- #!/bin/sh eval "exec perl -x $0 $* " #!perl require Math::BigInt; $x = Math::BigInt->new('123123123212317256961'); $y = Math::BigInt->new('65536'); ($q,$r) = $x->copy->bdiv($y); print "X = $x\n"; print "Y = $y\n"; print "Q = $q\n"; print "R = $r\n"; $y1 = $q*$y+$r; print "Y1 = $y1\n"; ($y1 == $y) || die "Got a situation here\n"; ------------------------------------------------ Results: X = 123123123212317256961 Y = 65536 Q = 1878709769999958 R = 65535 Y1 = 123123123486717313023 Got a situation here
From: jpeacock [...] rowman.com
[guest - Fri Apr 26 06:53:03 2002]: Show quoted text
> Code example: > -------------------------------------
<snip> Show quoted text
> $y1 = $q*$y+$r; > print "Y1 = $y1\n"; > > ($y1 == $y) || die "Got a situation here\n"; > > > ------------------------------------------------ > Results: > > X = 123123123212317256961 > Y = 65536 > Q = 1878709769999958 > R = 65535 > Y1 = 123123123486717313023 > Got a situation here >
You are going to kick yourself; you are comparing the wrong values in your test. But I see what you were trying to do; you need to get the newest Math::BigInt to get the correct answer. Try this instead: Show quoted text
> $x1 = $q*$y+$r; > print "X1 = $x1\n"; > > ($x1 == $x) || die "Got a situation here\n";
which using Math::BigInt v1.53 gives me X = 123123123212317256961 Y = 65536 Q = 1878709765812946 R = 27905 X1 = 123123123212317256961 which is correct. You can get the completely rewritten Math::BigInt here: http://search.cpan.org/search?dist=Math-BigInt The version of Math::BigInt that is currently associated with my ID was an interim fix; Tels has completely rewritten all of the modules (with my help/guidance/nagging). HTH John
Sorry, pay no attention to the last reply; I didn't log in so I didn't see that you were already using the latest M::BI. I need to find out how to transfer this bug report to Tels; I originally uploaded a mildly fixed version of the core modules before Tels rewrote them. So I got the bug report by mistake. I will forward your e-mail to Tels and work with getting the rt.cpan.org ticket forwarded as well. Sorry... John