I understand that the output 655535 is caused due to sign extension in statement (1), but what is happening in statement (2) that prevents this. Width of byte is 8 bits, so 'anding' it with 0xff should just result in byte value unchanged, shouldn't it?
BTW how can I print 'byte' as binary or hex strings?
Once you understand twos complement, and how a byte is sign extended when casting to a char, it should be straightforward. However, if you are still confused (after you get up to speed on twos complement), come back here, and elaborate what you don't understand.
Joined: Apr 06, 2009
come back here, and elaborate what you don't understand.
Dear sir, as you stated above that
please tell me what is the integer value stored in c before type casting into int.
please rectify the below code