[tpm] Math::BigInt issue
linux at alteeve.com
Sat Sep 12 13:09:05 PDT 2009
Sergio Salvi wrote:
> 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
> 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?
Yup, that was it. *Doh*. Here's what I needed to do to include the
(variable) size multiplied against it.
More information about the toronto-pm