I'm trying to understand the bitwise AND operator in C; it works until I put a 0 in front of 177.
I'm doing this by hand to make sure I understand what the compiler is doing
#include <stdio.h>
main () {
printf ("%d\n", 1999 & 177);
return 0;
}
The answer above is 129, this is my answer when I do it by hand as well
#include <stdio.h>
main () {
printf ("%d\n", 1999 & 0177);
return 0;
}
The compiler above gives me the answer 79, can someone please explain how it gets to the answer 79?
177 is base 10 (decimal) = 0xB1 = 02618.
0177 is base 8 (octal) = 12710 or 0x7F.
0x177 is base 16 (hexadecimal) = 37510 or 05678.