On Wed, 16 Jun 2004 12:03:36 +0200, Ard Biesheuvel <[EMAIL PROTECTED]> wrote:
Have you tested my initial re-implementation of crc32() on 64-bit architectures?
No, but I don't have to:
register unsigned long int crc = ~0ul;
... so crc = 0xffffffffffffffff
do { crc = (crc >> 8) ^ crc32tab[(crc ^ *p++) & 0xff]; n--; } while (n);
... which is xor'ed with crc32tab, which has 0x00000000 in the upper halves of all its elements.
This leads to the following a) the returned CRC is larger than 32 bits in the first 4 iterations, leading to incorrect results for strings of length up to 3; b) in the first couple of iterations, 1's have been shifted in instead of 0's, leading to incorrect results for strings of length 3 and up.
Which means it still works for all strings of length zero.
How's that for a BC break ?
-- Ard
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php