in reply to Re: Misunderstanding with Math::BigInt
in thread Misunderstanding with Math::BigInt

what do you mean by 'convert first the numbers to bigints' ?
  • Comment on Re^2: Misunderstanding with Math::BigInt

Replies are listed 'Best First'.
Re^3: Misunderstanding with Math::BigInt
by jgamble (Pilgrim) on Jun 30, 2005 at 21:20 UTC
    As your code stands now, your variables are handled solely by perl's own internal representation, and aren't converted into bigints until the very last minute, after the exponentation and multiplication. At that point it is too late to preserve the extra tens of digits that you want, because they aren't there to be preserved.

    Convert your $out, $driver, and $grade variables to bigints before you do any exponentation and multiplying.

    By the way, don't you mean to use Math::BigFloat instead?

    John
Re^3: Misunderstanding with Math::BigInt
by salva (Canon) on Jun 30, 2005 at 21:13 UTC
    my ($in_out) = @_; my ($out,$diver,$grade) = split(/,/, $in_out, 3); $out = Math::BigInt->new($out); my $rgrade = Math::BigInt->new(1/$grade); $diver = Math::BigInt->new($diver); my $in = $out**$rgrade*$diver;