[tpm] Math::BigInt issue

Sergio Salvi sergio at salvi.ca
Sat Sep 12 11:01:54 PDT 2009


You're letting Perl do the "2 ** 60" calculation, which will indeed be
limited. You want to tell Math::BigInt do to it for you:

my $value = Math::BigInt->new("2")->bpow("60");
# $value is 1152921504606846976

Sergio

On Sat, Sep 12, 2009 at 1:29 PM, Madison Kelly<linux at alteeve.com> wrote:
> Hi all,
>
>  Not sure if I am being daft or something, but it looks like Math::BigInt
> isn't returning a value I expected.
>
>  I'm doing a test to make sure that 1 exbibyte (2**60) returns, as I
> manually calculated, "1152921504606846976". Instead though, I get
> "1152921504606850000". This looks like it rounded off..
>
>  Can anyone see why then:
>
> my $size=1;
> my $bytes=Math::BigInt->new($size*(2**60));
>
>  Rounds off?
>
> Thanks!
>
> Madi
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>


More information about the toronto-pm mailing list