Re: use bigmnum




"gamo" <gamo@xxxxxxxxxxxx> wrote in message
news:Pine.LNX.4.64.0606161644010.11351@xxxxxxxxx

#!/usr/local/bin/perl -w

use bignum;

$fact=1;
for $i (2..1000){
$fact*=$i;
}
print "$fact\n";
$div = int ($fact/2003);
$resto = $fact - $div*2003;
# $resto = $fact % 2003;
print "$resto\n";

__END__

---------------------------------------------------

I think that what you wanted to achieve using int() should already be done
for you anyway - and calling int() leads to an error (for me, anyway) -
namely that $div then evaluates as 'NaN'.

However, it also looks like there's a bug in Math::BigInt.

For me $div (without the int call) is being evaluated as:
200892291601145169018323731364455309894800000000000000000000000000000000....

It should be:
200892291601145169018323731364455309894845164358819087640439296270563411....

You should file a bug report about this - or at least let the current
maintainer of the module know.

Both Math::Pari and Math::GMP should yield correct results.

Incidentally, for me (perl 5.8.8), '$resto = $fact % 2003;' evaluates
correctly.

Cheers,
Rob




.



Relevant Pages

  • Re: 15yr old with inc + div + int
    ... >> Normally, our son just has DIV and INT from a Schwab account, ... >Your son has to file file his own tax return (gross income greater than ...
    (misc.taxes)
  • Re: use bigmnum?
    ... use bignum; ... as int appears to be overloaded. ... But if $div == NaN, ... I don't imagine upgrading myself to 5.8.8 overnight. ...
    (comp.lang.perl.modules)
  • 15yr old with inc + div + int
    ... Normally, our son just has DIV and INT from a Schwab account, ... Last year he did some part time work. ...
    (misc.taxes)
  • Re: use bigmnum?
    ... use bignum; ... # This gives NaN for $div when I do it. ... as int appears to be overloaded. ...
    (comp.lang.perl.modules)
  • Re: use bigmnum
    ... For me $div (without the int call) is being evaluated as: ... I get this when I use the bigint pragma, rather than bignum. ...
    (comp.lang.perl.modules)