The most significant bit (MSB) is the leftmost bit of a binary number. "Significant" means "how much it matters": flipping the MSB changes the value more than flipping any other bit.
In an n-bit number the MSB is bit n − 1, with weight 2ⁿ⁻¹. In 8 bits it's bit 7, worth 128. In 4 bits it's bit 3, worth 8.
The MSB has extra jobs in signed formats:
- In twos complement, its weight is negative (−2ⁿ⁻¹), so MSB = 1 means the number is negative. It doubles as the sign bit.
- In sign magnitude, it is only a sign flag and has no weight at all.
- When widening a two's complement number, sign extension copies the MSB into every new bit.
It matters in arithmetic too. Signed overflow is detected by comparing the carry into the MSB column with the carry out of it.
Watch out: the MSB depends on the width. 0101 has MSB 0 in 4 bits, but written as 101 in 3 bits its MSB is 1. Always know how many bits you're working with.