in reply to Re^3: Math::BigInt and Leading Zeros
in thread Math::BigInt and Leading Zeros

You may not have tried a big enough number.

$ perl5.8.6 -MMath::BigInt -e '$i = Math::BigInt->new("123_456_789_000 +_000_000_000"); printf "%045d\n", $i' -00000000000000000000000000000000000000000001

Replies are listed 'Best First'.
Re^5: Math::BigInt and Leading Zeros
by radiantmatrix (Parson) on May 05, 2005 at 19:43 UTC
    You're still trying to use decimals (%d), when the parent suggested using strings (%s):
    use Math::BigInt; my $i = Math::BigInt->new('123_456_789_000_000_000_000'); printf qq'%045s\n', $i; __OUTPUT__ 000000000000000000000000123456789000000000000

    radiantmatrix
    require General::Disclaimer;
    s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}

      You're right. I completely and utterly missed that. Thanks.

      Oh, and thanks above - I didn't even realise that %s could take the 0 modifier. Which is probably why I missed the change from %d to %s!