Skip Menu |
 

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

Report information
The Basics
Id: 60838
Status: open
Priority: 0/
Queue: Math-BigRat

People
Owner: Nobody in particular
Requestors: hasch-cpan [...] cozap.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.24
Fixed in: 0.2602



Subject: should bit operations make Math::BigRat crash?
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 950
Download (untitled) / with headers
text/plain 950b
Hello, I think there is an issue with some overloaded operations Math::BigRat inherits from Math::BigInt but fails to properly override. Test Code follows: use Math::BigRat; $x = Math::BigRat->new('1') | 0; Can't use an undefined value as an ARRAY reference at .../Math/BigInt/Calc.pm line 1175. Math::BigInt::Calc::_acmp('Math::BigInt::FastCalc', undef, undef) called at .../Math/BigInt/Calc.pm line 2142 Math::BigInt::Calc::_or('Math::BigInt::FastCalc', undef, undef) called at .../Math/BigInt.pm line 2105 Math::BigInt::bior('Math::BigRat=HASH(0x80fb0c)', 0) called at .../Math/BigInt.pm line 129 Math::BigInt::__ANON__('Math::BigRat=HASH(0x803030)', 0, '') called at test.pl line 2 I had expected an error message telling me that "bitwise or" is not implemented for rationals, or, since this particular value is actually an integer, success. I am using Math::BigRat version 0.24, Math::BigInt version 1.89_01, perl 5.12.1. -Martin
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-11062-1283020319-552.60838-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 119
Download (untitled) / with headers
text/plain 119b
Hello again, I noticed this might actually be a Math::BigFloat / Math::BigInt issue, see rt.cpan.org #59615. -Martin
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-11334-1350250699-1994.60838-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 658
Download (untitled) / with headers
text/plain 658b
On Sat Aug 28 13:53:11 2010, MHASCH wrote: Show quoted text
> Hello, > > I think there is an issue with some overloaded operations Math::BigRat > inherits from Math::BigInt but fails to properly override. Test Code > follows: > > use Math::BigRat; > $x = Math::BigRat->new('1') | 0; > > Can't use an undefined value as an ARRAY reference at > .../Math/BigInt/Calc.pm line > 1175. > > I had expected an error message telling me that "bitwise or" is not > implemented for > rationals, or, since this particular value is actually an integer, > success.
Math::BigRat 0.2601 displays error (this change is not documented in Changes). -- Alexandr Ciornii, http://chorny.net
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-11334-1350250699-1994.60838-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-11334-1350250699-1994.60838-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-4252-1350286449-1738.60838-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 562
Download (untitled) / with headers
text/plain 562b
Currently, Math::BigRat and Math::BigFloat inherit from Math::BigInt. I consider this a design flaw and has caused several bugs, including this one. If I remember correctly, the only method it makes sense to inherit from Math::BigInt is sign(). Math::BigRat and Math::BigFloat also use some utility functions in Math::BigInt. I think a good start is to create a virtual parent class, e.g., Math::BigNum, and move sign() and the utility functions into that namespace, and let Math::BigInt, Math::BigRat, and Math::BigFloat inherit from this virtual parent class.


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.