ID: 51073 User updated by: jian at theorchard dot com Reported By: jian at theorchard dot com Status: Bogus Bug Type: Feature/Change Request Operating System: Linux RHEL 5 PHP Version: 5.3.1 New Comment:
As I had previously said, forget it because it's platform related issue not PHP's fault. I was trying to say it would be nice if the end user didn't need to do this kind of re-formatting. It would nice the function acts as a black box. That's all. Thank you all for replying to my post. And I feel very sorry to have wasted all of you time on this stupidity. At least my boss was very understanding what I had to deal with. Please close this ticket. I'm not going to post anything more here. Thank you. Previous Comments: ------------------------------------------------------------------------ [2010-02-19 13:39:56] ras...@php.net But, like I said there is nothing to do here. We have to return the exact bits. Anything we do other than that will cause all sorts of chaos and confusion. So I don't understand what you are asking for, A new datatype in PHP for this? That's not going to happen obviously. ------------------------------------------------------------------------ [2010-02-19 13:36:39] paj...@php.net Not too hard to understand that PHP has no unsigned integer type. ------------------------------------------------------------------------ [2010-02-19 13:33:47] jian at theorchard dot com Did you not read my previous post? That's the same exactly function I have already posted. Yes, it is very stupid to have to do that on the user's end. ------------------------------------------------------------------------ [2010-02-19 05:15:56] ras...@php.net Why can't you always use a signed checksum if that is what you want? crc32 simply returns 32 bits. You always get the same 32 bits regardless of the platform. If you want to always represent that as a signed 32-bit integer, then do so. The fact that some platforms have the ability to show those 32 bits without messing up the sign is irrelevant. Just emulate it with something stupidly simple like: $max32 = 2147483648; $crc = crc32("884385799717_1_1"); if($crc>$max32-1) { $crc = $crc-2*$max32; } echo $crc; ------------------------------------------------------------------------ [2010-02-19 04:20:00] jian at theorchard dot com All I was saying is to point out that crc32 function is unable to return the same result represented in the same way under any different platforms. The documentation does say to use sprintf function to format the result to be an unsigned integer in order to the get same expected result from all platforms. In the real world, we actually do need to use signed checksum in some cases. So with this shortcoming in mind, crc32 function cannot achieve a truly signed checksum purpose. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/51073 -- Edit this bug report at http://bugs.php.net/?id=51073&edit=1