(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
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
> It is hard to judge what "widely supported" means. PHP is so widespread
> that people run it on embedded systems, 10+ year old servers (see old
> masters.php.net) and compile them with compiler most of us have never
> touched (suncc, pcc).
Both suncc and pcc support C99. Are you aware of any oth
A feature of C11 that would be useful is anonymous unions:
struct zval {
union {
long lval;
double dval;
};
enum {
IS_LONG,
IS_DOUBLE
} type;
};
int main(void) {
struct zval zv;
zv.lval = 1;
zv.type = IS_LONG;
return 0;
}
Again, thi
> Again, this is a C11 feature. It is supported by clang, gcc and MSVC.
To clarify this a bit: they permit anonymous unions in C89 and C99
code (meaning you do not need to pass flags like -std=c11 to enable
it).
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http: