Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with >> on some php version #2

Open
emeric0101 opened this issue Jan 27, 2017 · 3 comments
Open

Bug with >> on some php version #2

emeric0101 opened this issue Jan 27, 2017 · 3 comments

Comments

@emeric0101
Copy link

Hi, i have a fix to suggest :
In the function mx(), in my server, i had an issue with right byte shifting in $y >> 3 because it returned negative values.
For fixting it : (from http://stackoverflow.com/questions/2642026/php-equivalent-javascript-shift-right-with-zero-fill-bitwise-operators )

private static function rightShift($x, $c)
          {
              $x = intval ($x); // Because 13.5 >> 0 returns 13. We follow.
              $nmaxBits = PHP_INT_SIZE * 8;
              $c %= $nmaxBits;
              if ($c)
                  return $x >> $c & ~ (-1 << $nmaxBits - $c);
              else
                  return $x;
          }

then replace eveywhere you use x << y

@andot
Copy link
Member

andot commented Jan 30, 2017

In mx(), I have used ($y >> 3 & 0x1fffffff) to fix negative value. Does it not work?

@emeric0101
Copy link
Author

Yes it works fine,
but it is not released, so when I use composer, i get the older version of your code.

@andot
Copy link
Member

andot commented Jan 31, 2017

Oh, I released it now.

And you can also use xxtea-pecl to instead this pure php implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants