develooper Front page | perl.perl5.porters | Postings from January 2010

Re: [perl #70109] The bignum module changes behavior ofMath::BigInt::bdiv()

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
January 20, 2010 14:13
Subject:
Re: [perl #70109] The bignum module changes behavior ofMath::BigInt::bdiv()
Message ID:
20100120221310.GQ2944@iabyn.com
On Thu, Oct 29, 2009 at 10:21:18AM -0700, jl_post@hotmail.com (via RT) wrote:
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use Math::BigInt;
> my $n = Math::BigInt->new(6);
> 
> print "\$n before \$n->bdiv(2): $n\n";  # prints 6
> $n->bdiv(2);
> print "\$n after \$n->bdiv(2): $n\n";  # should print 3
> 
> # use bignum;

[snip]

> However, if I uncomment the "use bignum;" line (that last
> line of the script, right before the __END__ tag) and re-run
> the code, I get this output (on both Linux and Strawberry Perl
> for Windows):
> 
> $n before $n->bdiv(2): 6
> $n after $n->bdiv(2): 6
> 
> Notice that now the second line says that $n is 6.
> (It should say 3.)
> 
> Evidently just the inclusion of the "bignum" module is causing
> the Math::BigInt::bdiv() method to behave differently (in that
> it is not modifying the calling object).

It's actually a big in BigInt.pm or BigFloat.pm; the 'use bignum' just
sets an internal flag, as can be seen below:

    use Math::BigInt;
    use Math::BigFloat;

    my $fn = Math::BigInt->new(6);
    $Math::BigInt::upgrade ='Math::BigFloat'; # side-effect of 'use bignum';
    $fn->bdiv(2);

    print "result (should be 3): $fn\n";

Jesse, given that Big* are CPAN modules and that this bug is present in
5.8.*, I can't see that this bug should be a 5.12 showstopper.

Also, does anyone know if there's a way to transfer this to the
appropriate CPAN RT queue, since its not a core bug? Or does one just ask
the originator to re-report it?


-- 
That he said that that that that is is is debatable, is debatable.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About