문제

I feel I'm missing something basic about number system but I'm really confused with below piece of code I'm trying to play with bitwise operators:

x=56;
printf("\nHere  :\n%x   %x\n",x,077);
x=x& ~077;
printf("%x\n",x);

It considers 077 as octal(hex 3f). And if I put only 77 it treats it as decimal (hex 4d). If put 177 , its treated as decimal(hex b1). I'm referring the book C programming by Richie and Kernighan.

Please help.

도움이 되었습니까?

해결책

All exactly as expected. Start with a 0 and it's octal. Start with 0x and it's hex. Otherwise, it is decimal.

What is the problem?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top