Menu

Binary and Hexadecimal Basics

Binary

Binary is a number system that is base 2: it uses only two digits, 0 and 1. Every place in a binary number is worth twice as much as the place to its right, so the place values double as you move left.

Place values

In an 8-bit binary number the place values from left to right are 128, 64, 32, 16, 8, 4, 2 and 1. A nibble is 4 bits, so it uses only the place values 8, 4, 2 and 1.

Position in an 8-bit numberPlace value
1st (leftmost)128
2nd64
3rd32
4th16
5th8
6th4
7th2
8th (rightmost)1

Each 1 adds the place value of its position and each 0 adds nothing, so you only add up the places that hold a 1. In the nibble 1010 the 1s are in the 8 and 2 places, so the value is 8 + 2 = 10. In the 8-bit number 10011000 the 1s are in the 128, 16 and 8 places, giving 128 + 16 + 8 = 152.

Leading zeros and length

Leading zeros are zeros written to the left of the first 1. They do not change the value of a binary number because those places add nothing. For example, 111 and 00000111 both have the value 7. Binary values are often padded with leading zeros to 8 bits so that a whole byte is written out and values line up neatly when you compare them.

A binary number does not have to be exactly eight bits long to be valid. Binary values you will meet can be anything from 1 to 8 bits, so 1, 101 and 11010110 are all valid binary values. Eight bits is just a common, consistent length.

Practise this

OCR GCSE Computer Science · Binary and Hexadecimal Basics