Skip Menu |
 

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

Report information
The Basics
Id: 12857
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Math-BigInt

People
Owner: TELS [...] cpan.org
Requestors: jameshippisley [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.77
Fixed in: (no value)



Download (untitled) / with headers
text/plain 1.3k
Another issue I'm noticing... Technically, I'm not sure if this is a Math::BigInt bug, or an Overload bug, but it can be fixed (or atleast worked around) in Math::BigInt. Anyhow, I am deriving a class BigVal from Math::BigInt. When I do certain base 2 brsft's for negative numbers using this class, I get the wrong result. I have tracked down the problem to the fact that overloaded comparison of a BigVal against an int only works if the BigVal appears first. For a Math::BigInt, the order doesn't matter. A fix is to change line 1805 of BigInt.pm to if ($y >= CORE::length($bin)) { Test case: #!/usr/local/bin/perl5.8.6 -w use Math::BigInt lib => 'GMP'; @BigVal::ISA = qw(Math::BigInt); my $x = new BigVal(1); my $y = new Math::BigInt(1); print "(3<=x) =>", 3 <= $x, "\n"; # wrong! print "(3<=y) =>", 3 <= $y, "\n"; print "(x>=3) =>", $x >= 3, "\n"; print "(y>=3) =>", $y >= 3, "\n"; my $v1 = new BigVal("0x100000000")->bneg->brsft(31); my $v2 = new Math::BigInt("0x100000000")->bneg->brsft(31); $v1 != $v2 and print "Something wrong!\n"; package BigVal; use overload; output: Use of uninitialized value in numeric le (<=) at /home/jrob/junk/test2.pl line 9. (3<=x) =>1 (3<=y) => (x>=3) => (y>=3) => Use of uninitialized value in numeric le (<=) at BigInt.pm line 1805. Something wrong! can give the wrong result
Download (untitled) / with headers
text/plain 386b
[guest - Tue May 17 12:41:53 2005]: Show quoted text
> Another issue I'm noticing... Technically, I'm not sure if this is a > Math::BigInt bug, or an Overload bug, but it can be fixed (or > atleast worked around) in Math::BigInt.
Ugh, I already released v1.77 - should have waited until my head clears from the flu :) I'll look into this tomorrow... thanx for the report! best wishes, tels
Download (untitled) / with headers
text/plain 133b
Thanx, I have applied your change (swapped$y to the left) to my local copy, and it will be released as 1.80 soon. Best wishes, Tels
Download (untitled) / with headers
text/plain 125b
I just released Math::BigInt 1.80 to CPAN, which fixes this issue. Thank you for your report, and sorry for the long delay.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.