Skip to content

Commit

Permalink
Use gmp_intval for better integer casting
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Oct 28, 2015
1 parent f904bcf commit 1493640
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Optimus.php
Expand Up @@ -73,7 +73,7 @@ public function encode($value)
switch (static::$mode)
{
case self::MODE_GMP:
return ((int) gmp_mul($value, $this->prime) & static::MAX_INT) ^ $this->xor;
return (gmp_intval(gmp_mul($value, $this->prime)) & static::MAX_INT) ^ $this->xor;

default:
return (((int) $value * $this->prime) & static::MAX_INT) ^ $this->xor;
Expand All @@ -96,7 +96,7 @@ public function decode($value)
switch (static::$mode)
{
case static::MODE_GMP:
return (int) gmp_mul((int) $value ^ $this->xor, $this->inverse) & static::MAX_INT;
return gmp_intval(gmp_mul((int) $value ^ $this->xor, $this->inverse)) & static::MAX_INT;

default:
return (((int) $value ^ $this->xor) * $this->inverse) & static::MAX_INT;
Expand Down

0 comments on commit 1493640

Please sign in to comment.