in reply to Re^2: decimal to binary conversion need help
in thread decimal to binary conversion need help

I don't know what the restrictions are with "use bigint", but it dosn't give the same result.???? Differ by 1.
#!/usr/bin/perl use Math::BigInt; my $bignum = Math::BigInt->new(9007199254740991); print $bignum->as_bin(),"\n"; ######################################################## use bigint; my $bignum = 9007199254740991; print $bignum->as_bin(),"\n"; __END__
Results:

0b11111111111111111111111111111111111111111111111111110 0b11111111111111111111111111111111111111111111111111111

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^4: decimal to binary conversion need help
by zentara (Cardinal) on Jan 06, 2005 at 12:47 UTC
    Oops, I guess BigInt wants a string, not a number.
    my $bignum = Math::BigInt->new('9007199254740991'); print $bignum->as_bin(),"\n"; ######################################################## use bigint; my $bignum = 9007199254740991; print $bignum->as_bin(),"\n";
    #Correct results:
    0b11111111111111111111111111111111111111111111111111111 0b11111111111111111111111111111111111111111111111111111

    I'm not really a human, but I play one on earth. flash japh
      Thank you for all this help, but i have another problem i am running the code on perl 5.6 and it seems that it is not working please help
        what is the error message?
        i donīt know if Math::BigInt.pm or bigint.pm is a perl 5.6 core module. if not then install it.