i dont understand the difference between an signed var and an unsigned var. i couldnt find a definition in the book im using
thanks,
-nabeel
Printable View
i dont understand the difference between an signed var and an unsigned var. i couldnt find a definition in the book im using
thanks,
-nabeel
An unsigned 8-bit integer can have a value of 0 to 255 inclusive. A signed 8-bit integer can have a value of -128 to 127 inclusive. That's the main difference.
Signed integers are represented using two's complement binary representation, whereas unsigned values are what you will be more familiar with. If you want to know how they differ look up "two's complement".
Whenever a variable will never hold a negative value, make it unsigned.