- Can anyone please tell me that why in signed char range -128 is equal to +128, -127 is equal to +129 and so on. Although in signed range 0 represents positive values most significant bit 1 reserved for negative number. (Explain with binary representation please.)
- Why actually we need of signed range in char, isn't unsigned range enough for computation.
Asked
Active
Viewed 28 times
0

kiner_shah
- 3,939
- 7
- 23
- 37

Xinther3q3
- 1
- 2
-
2bits are bits are bits. However you interpret them is up to you. I don't know if the C standard makes any rules about the values of signed char, but on every system I've ever used, [`CHAR_BIT`](https://stackoverflow.com/questions/3200954/what-is-char-bit) has been 8 (this is not guaranteed by the standard) for a range of [-128, +127]. In `unsigned char`, these very same bits are interpreted as values [0, +255]. Not quite sure what you're asking, negative numbers have application to all fields of science and beyond, it's good we've created computers to work with them. – yano Nov 05 '21 at 05:05
-
I simply mean that why we actually use signed char.in binary representation + 128 is same as -128 & so on.then actually what's the function of signed char. – Xinther3q3 Nov 17 '21 at 00:21
-
you must be talking about 2s compliment. You just said it yourself. If you see `0b1000 0000`, what does that mean? Who knows? Impossible to answer without context. If it's a `signed char`, then it's -128. If it's an `unsigned char` then it's +128. If it's your own made up encoding scheme then maybe it's something entirely different. There's a big difference between -128 and +128. What if I sent that value to control a digital motor? It better know + or - or it will spin the wrong way, might wreck the car, kill somebody. – yano Nov 17 '21 at 04:11