Start here · Essential guide
Signed vs Unsigned Integers in C++
Learn how signed and unsigned integers differ in C++, including their value ranges, wraparound, sign bits and the comparison bugs that mixing them causes.
Syntax and Functions
How signed and unsigned integers differ and how they look in binary.
Start here · Essential guide
Learn how signed and unsigned integers differ in C++, including their value ranges, wraparound, sign bits and the comparison bugs that mixing them causes.
Binary is the same bits read two ways. Unsigned numbers hold zero and positive values, while signed numbers use the leftmost bit for negatives too.
11111111 is 255 as an unsigned 8-bit number and -1 as a signed one in two's complement. Here is how the sign bit changes the reading, with C++ code.
Related topics