0

I want to shift the variable x so the result would be: 0000 0000 0000 1111

    int x = 1111 0000 0000 0000;
    int z = x >> 12;

    printf("%d", z);

But it is not working. First, I can not compile the program because I get the error:

"error: expected ',' or ';' before numeric constant"

And second, when I delete the whitespace between the numbers in the int x, I get the result "-162425". But I want the result to be: "0000 0000 0000 1111".

It feels like the program doesn't know that int x should be seen as a binary number, not as an integer.

Should I use something else than int, is there any data type so I can get the result I want?

0 Answers0