ID:               51073
 Updated by:       ras...@php.net
 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:

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.


Previous Comments:
------------------------------------------------------------------------

[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.

------------------------------------------------------------------------

[2010-02-18 08:34:59] ras...@php.net

It does return the correct set of bits.  Anything we do to change what

is currently being returned will seriously confuse everyone and the 
documentation is quite clear on this.

------------------------------------------------------------------------

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

Reply via email to