On Thursday 23 December 2004 16:18, Roger Thomas wrote:
> I want to convert negative number to its positive equivalent.
>
> $num = -40;
> printf("Unsigned value is %u", $num);
>
> output is: Unsigned value is 4294967256
>
> I have checked the manpages and %u seems the right format. Pls advise.
You
I believe this is because taking a value and displaying it as an unsigned value
isn't the same as displaying the absolute value of a number.
Ever take a calculator that does hex and decimal, enter a negative number then
convert it to hex? There's no negative in hex, so you end up with something
unsigned does not equal absolute value.
$num = -40;
print "Num: $num\n";
$num = abs($num);
print "ABS: $num\n";
will display:
Num: -40
ABS: 40
http://us2.php.net/manual/en/function.abs.php
Justin
- Original Message -
From: "Roger Thomas" <[EMAIL PROTECTED]>
To:
Sent: Thursday, December 23
3 matches
Mail list logo