Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

What is the >>>= operator in C?

Given by a colleague as a problem, I cannot find out how this C program really compiles and runs. What is this >>>= operator and the strange 1P1 literal? I have tested in Clang and GCC. There are no signs and the output is "???"

#include <stdio.h>

int main()
{
int a[2]={ 10, 1 };

while( a[ 0xFULL?'\0':-1:>>>=a<:!!0X.1P1 ] )
printf("?");

return 0;
}
by

1 Answer

sandhya6gczb
This is a more readable version:

while( a[ 0xFULL ? '\0' : -1 ] >>= a[ !!0X.1P1 ] )

and an even more readable version, replacing the expressions in the [] for the values they resolve to:

while( a[0] >>= a[1] )

Replacing a[0] and a[1] for their values should make it easy to figure out what the loop is doing, i.e. the equivalent of:

int i = 10;
while( i >>= 1)

which is simply performing (integer) division by 2 in each iteration, producing the sequence 5, 2, 1.

Login / Signup to Answer the Question.