+ 1
Please, Explain the following...
signed char chr; chr = 128; printf("%d",chr); //Output is : -128 //How ???
2 odpowiedzi
+ 3
signed char range is -128 to 127 according to the 2-complement representation.
So, we have overflow and it will be round-off to fit it in the range.
That’s why, 128 round-off to -128.
/*
signed char chr = 128 prints ==> -128
signed char chr = 129 prints ==> -127
signed char chr = 130 prints ==> -126
...
signed char chr = 255 prints ==> -1
signed char chr = 256 prints ==> 0
signed char chr = 257 prints ==> 1
...
*/
+ 2
ok... i got it thanks for your help...