M
Martin Dickopp
Correct, so far.
Why? Both operands have type int.
You are correct, of course. I have been severely confused.
Martin
Correct, so far.
Why? Both operands have type int.
Joona said:Perhaps I should have explained in more detail. The ~ operator
implements one's complement arithmetic by inverting all the bits. Thus
you get "all-bits-one" for ~0, because "all-bits-zero" is 0.
But! If the number is signed, two's complement arithmetic comes into
play *after* that. On a two's complement machine, any number whose
leftmost bit is 1 is taken as negative, and "all-bits-one" is -1 on
such a machine. Therefore, on a two's complement machine, ~0 == -1.
Joona I Palaste said:Perhaps I should have explained in more detail. The ~ operator
implements one's complement arithmetic by inverting all the bits. Thus
you get "all-bits-one" for ~0, because "all-bits-zero" is 0.
Christopher Benson-Manica wrote: said:Is 0 indeed equivalent to 0x00000000? (I ask because I don't know...)
Christopher said:Is 0 indeed equivalent to 0x00000000? (I ask because I don't know...)
Is 0 indeed equivalent to 0x00000000? (I ask because I don't know...)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.