* Thus wrote Cody Phanekham ([EMAIL PROTECTED]): > Im trying to retrieve the unsigned value of an integer. sounds pretty simple... > > [code] > $i = -86; > echo "<br>" . sprintf("%d", $i); > echo "<br>" . sprintf("%u", $i); > [/code] > > produces: > -86 > 4294967198 > > what i expected: > -86 > 86 > > Ive searched the archives but most of the messages refer to %s or %d... nothing in > regards to %u What you want is abs()
http://php.net/abs > can anyone see what im doing wrong? You're expecting wrong results. Signed and Unsigned integers are stored identical bit by bit. The only difference is that in signed the last bit is reserved for the sign (0 = positive 1 = negative), whereas in the unsigned the 1 makes the number bigger by (sizeof(int)^2)-1 [i think my math is right on that] HTH, Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php