I have an 11 digit number. I want to add another number to it and format to 11 digits as well.
my $amount1 = 14313562897; my $amount2 = 00000013625; $amount = sprintf("%011d", $amount1 + $amount2); print $amount."\n"; The answer perl gives me is -0000000001 How can this be ? --- When a number begins with a 0 , perl treats it as an octal value and performs octal arithmetic for example 020 + 0101 = (2*8 + 0*1) + ( 1*(8^2) + 0*(8^1) + 1*(8^0) ) = (16) + (64+1) = 81 --- As well, if the large number starts with 0, I get an "Illegal octal digit '8' at test.pl line 2, at end of line". As though perl cant handle numbers bigger than 10 digits or so. ???? --- If your big number starts with 0 and contains digits between 0 and 7 there should not be any complaints by perl. HTH, Chetak -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>