Re: [PHP-DEV] [PATCH] random_int: Fix power of two check.

2015-05-10 Thread Nikita Popov
On Sun, May 10, 2015 at 12:40 PM, Lauri Kenttä wrote: > (x & ~x) is always 0. > ((x & (~x + 1)) != x) works. > ((x & (x - 1)) != 0) works too. > --- > ext/standard/random.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ext/standard/random.c b/ext/standard/random.c > in

[PHP-DEV] [PATCH] random_int: Fix power of two check.

2015-05-10 Thread Lauri Kenttä
(x & ~x) is always 0. ((x & (~x + 1)) != x) works. ((x & (x - 1)) != 0) works too. --- ext/standard/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/random.c b/ext/standard/random.c index 12c2503..4a1adbf 100644 --- a/ext/standard/random.c +++ b/ext/standar