Why is the output -33 for this code snippet

前端 未结 3 1125
没有蜡笔的小新
没有蜡笔的小新 2021-01-23 05:54
#include

int main()
{
    int a=32;
    printf(\"%d\\n\", ~a);  //line 2
    return 0;
}

o/p = -33

Actually in the original snippet li

3条回答
  •  故里飘歌
    2021-01-23 06:26

    Most computers use two's complement representation for negative numbers. See here: http://en.wikibooks.org/wiki/A-level_Computing/AQA/Problem_Solving,_Programming,_Data_Representation_and_Practical_Exercise/Fundamentals_of_Data_Representation/Two%27s_complement

提交回复
热议问题