Hi, Friday, October 3, 2003, 4:39:32 PM, you wrote: CP> Yeah abs() looks like it would do the trick
CP> I wonder if the same output would be generated using C's sprintf() CP> Too bad i dont have access to C... oh well >> -----Original Message----- >> From: Tom Rogers [mailto:[EMAIL PROTECTED] >> Sent: Friday, 3 October 2003 16:27 >> To: Tom Rogers >> Cc: Cody Phanekham; [EMAIL PROTECTED] >> Subject: Re[2]: [PHP] unexpected results using sprintf() with %u >> >> >> Hi, >> >> TR> -86 actually looks like FFFFFFAA which if you then look >> at unsigned is pretty >> TR> big :) >> >> TR> -- >> TR> regards, >> TR> Tom >> >> Maybe what you need is the abs() function which ignores the >> sign of a number >> >> -- >> regards, >> Tom >> >> >> CP> ************************************************************************************* CP> This e-mail, including any attachments to it, may contain confidential and/or personal 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 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 anti-virus systems. CP> For more information, visit our website at www.salmat.com.au. CP> ************************************************************************************* C would do exactly the same, it is the way in which negative numbers are represented 1 = 01 in hex 0 = 00 in hex -1 = FF in hex -2 = FE in hex now if we forget about being negative FF becomes 255 and FE becomes 254 and so on. Where they cross over is 7F is the largest positive and 80 is the most negative (using 1 byte). Using 2 bytes it would be 7FFF and 8000. Hope that explains it -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php