PHP on Solaris (2.6) and integer overflow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • writeson@charter.net

    PHP on Solaris (2.6) and integer overflow

    Hi all,

    I have PHP version 4.4 installed on a Soaris 2.6 system and I'm getting
    strange results doing math/boolean operators. I have a hashing
    algorithm that does multiplication, bitwise operations and mod() calls
    interatively on the characters of a filename. On a linux platform the
    multiplications start to overflow (as I expect) and the overflow is
    just dropped. The lower three bytes are masked off like this:

    $result = $result & 0x00FFFFFF;

    and the loop continues. On the Solaris platform the multiplication
    fails very quickly in the loop, and it looks like the overflow bits are
    wrapped around onto the lower order bytes, eventually I end up with an
    interger value of 0x00FFFFFF because of the masking above. To solve the
    problem I had to compile the gmp_* function support into PHP and work
    with the gmp_* family of functions.

    Has anyone ever seen this behavior before, and if so can you enlighten
    me about it?

    Thanks,
    Doug

Working...