Re: stripping negative number
| From: | Jason Wong | Date: | Thu, 23 Dec 2004 08:58:01 +0000 |
| Subject: | Re: stripping negative number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-205054@lists.php.net to get a copy of this message | ||
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've misunderstood what the unsigned representation means.
The correct function to use is abs().
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
No matter whether th' constitution follows th' flag or not, th' supreme
court follows th' iliction returns.
ollo -- Mr. Dooley
*/