How do I write this C expression in J? (where x is input integer, and a is temporary variable)
((a= ~x & (~x >> 1)) ^= a ? 0 : (a ^ (a & (a - 1))) | (a ^ (a & (a - 1))) << 1);
.
Edit:
In a more readable form:
int a = (~x) & ((~x) >> 1);
if (a == 0) return 0;
int b = a ^ (a & (a - 1));
return b | (b << 1);
Without testing, the basic transcription would be something like this:
But there could be a smarter approach.