c - Bits representation of negative numbers -
This is a doubt about the representation of bits of signed integer, for example, when you want to represent -1 , Then it is equal to the complement of 2 (+1). So -1 is shown as 0xFFFFFFF Now when I change my number to 31 and print the result it is coming back as -1.
signed int a = -1; Printf (("number is% d", (a> 31)); // it is print-1; would someone tell me how bits are represented for negative numbers? Thank you.
When the top bit is zero, then the number is positive. , The number is negative.
Negative numbers have been moved to move "1" to keep the number negative as the topmost part This is the reason that you are getting this answer.
For more about two supplements, see.
@brob show that instead of some implementation 1 1. [Verified Wikipedia]. This dependence in Java is an arithmetic change.
But the output given by the questioner shows that its compiler is doing arithmetic changes .
Comments
Post a Comment