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: use bigmnum?
    ... gamo wrote: ... use bignum; ... as int appears to be overloaded. ... But if $div == NaN, ...
    (comp.lang.perl.modules)
  • 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)
  • Re: repeating fraction part
    ... The reason it does not meet your specification is that when you have a reduced fraction n/d and it repeats, the cycle is in general d digits long. ... [Hint 1: check the current gcd of the numerator and denominator after each digit is generated; Hint 2: when n> d, the cycle length is probably wrong, check it] ... int gcd_aux ... div = gcd; ...
    (comp.lang.c)
  • 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)