i have following code:
#include <iostream> using namespace std; int main() { int val = 16; printf("%d\t%d\t",val,val & 017); return 0; } why output
16 0 and not
16 16 as expect boolean operation
16 , 17 = 16
the literal 017 interpreted octal representation because starts 0. details on see e.g. here. note that
(17)_8 == (15)_10 == (1111)_2 and (16)_10 == (10000)_2 result clear.
Comments
Post a Comment