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 = 0013625;
$amount = sprintf("%011d", $amount1 + $amount2);
print $amount."\n";
The answer perl gives me is -01
How can this be ?
---
When a nu
On Fri, 26 Nov 2004 17:47:25 +1100, David Clarke wrote:
> 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".
Sorry, forgot this one. A number can't start with a zero (except if it is in
front of a comma). If a number starts with a z
On Fri, 26 Nov 2004 17:47:25 +1100, David Clarke wrote:
> my $amount1 = 14313562897;
> my $amount2 = 0013625;
> $amount = sprintf("%011d", $amount1 + $amount2);
> print $amount."\n";
>
> The answer perl gives me is -01
> How can this be ?
>
> As well, if the large number starts with 0
Hi Dave,
my $amount2 = 0013625;
As you pointed already.
0 is an octal constant
$amount = sprintf("%011d", $amount1 + $amount2);
and: printf "%d" casts to a signed int
unfortunately the printf interface doesn't give a good way to say "deal
with this number, whether perl stored it as si
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 = 0013625;
$amount = sprintf("%011d", $amount1 + $amount2);
print $amount."\n";
The answer perl gives me is -01
How can this be ?
As well, if th