Re: unexpected results using sprintf() with %u

From: Date: Fri, 03 Oct 2003 06:16:10 +0000
Subject: Re: unexpected results using sprintf() with %u
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-164854@lists.php.net to get a copy of this message
Hi, Friday, October 3, 2003, 3:51:59 PM, you wrote: CP> Im trying to retrieve the unsigned value of an integer. sounds pretty simple... CP> [code] CP> $i = -86; CP> echo "<br>" . sprintf("%d", $i); CP> echo "<br>" . sprintf("%u", $i); CP> [/code] CP> produces: CP> -86 CP> 4294967198 CP> what i expected: CP> -86 CP> 86 CP> Ive searched the archives but most of the messages refer to %s or %d... nothing in regards to CP> %u CP> can anyone see what im doing wrong? CP> Im using PHP 4.3.2 CP> TIA CP> Cody CP> ************************************************************************************* CP> This e-mail, including any attachments to it, may contain confidential and/or personal CP> information. CP> If you have received this e-mail in error, you must not copy, CP> distribute, or disclose it, use or take any action CP> based on the information contained within it. CP> Please notify the sender immediately by return e-mail of the error and then delete the CP> original e-mail. CP> The information contained within this e-mail may be solely the opinion CP> of the sender and may not necessarily CP> reflect the position, beliefs or opinions of Salmat on any issue. CP> This email has been swept for the presence of computer viruses known to Salmat's CP> anti-virus systems. CP> For more information, visit our website at www.salmat.com.au. CP> ************************************************************************************* CP> -- CP> PHP General Mailing List (http://www.php.net/) CP> To unsubscribe, visit: http://www.php.net/unsub.php -86 actually looks like FFFFFFAA which if you then look at unsigned is pretty big :) -- regards, Tom

« previous php.general (#164854) next »