Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Competitions › SOF ICSO › unit 1 of 16

Binary numbers

SOF ICSO · Computer Science · about 7 minutes

Computers store everything as 0s and 1s. Each binary place is worth double the one to its right: 1, 2, 4, 8, 16, 32, 64, 128.

Flip the switches and watch the decimal value; press Count up to see binary counting.

In this lesson

  1. Place values that double
  2. Decimal to binary
  3. Bits, bytes and other bases
  4. Worked examples
  5. Where marks are lost
  6. Check yourself

1Place values that double

In decimal each place is worth 10 times the one to its right: ones, tens, hundreds. In binary each place is worth 2 times: 1, 2, 4, 8, 16, 32, 64, 128. A binary digit (bit) is 0 or 1.

So 1011 in binary is 8 + 0 + 2 + 1 = 11.

2Decimal to binary

Divide by 2 again and again and write down the remainders; read them from the bottom up. 13 ÷ 2 = 6 r 1, 6 ÷ 2 = 3 r 0, 3 ÷ 2 = 1 r 1, 1 ÷ 2 = 0 r 1, so 13 = 1101.

Or subtract the biggest power of 2 that fits: 13 = 8 + 4 + 1.

3Bits, bytes and other bases

8 bits make a byte, which can hold 2⁸ = 256 values (0 to 255). n bits give 2ⁿ patterns.

Hexadecimal groups 4 bits into one digit 0–9, A–F: 1111 = F = 15, so 1111 1111 = FF = 255. Octal groups 3 bits.

Worked examples

  1. Example 1Convert 45 to binary.

    1. 45 = 32 + 8 + 4 + 1.
    2. Places 32, 16, 8, 4, 2, 1 → 1, 0, 1, 1, 0, 1.

    Answer: 101101

  2. Example 2Add 1011 and 0110 in binary.

    1. 11 + 6 = 17 in decimal.
    2. 17 = 16 + 1 = 10001.

    Answer: 10001

Where marks are lost

  • Reading the remainders top to bottom instead of bottom to top.
  • Forgetting that 1 + 1 = 10 in binary (write 0, carry 1).
  • Thinking a byte holds values up to 256: it is 0 to 255.

Exam tips

  • To convert to binary, keep dividing by 2 and read the remainders bottom-up.
  • 8 bits = 1 byte; 1 kilobyte ≈ 1,000 bytes.
  • Hexadecimal uses 0–9 and A–F: one hex digit is four bits.

Practice questions

  1. What is 1011 in binary as a decimal number?

  2. What is 20 in binary?

  3. How many bits are in a byte?

More worked examples

Try each one first, then open the working.

  1. Add the two binary numbers. What is the answer in decimal?

    128064132116080412010+00110011?
    Show the working

    Start: Change each to decimal, or add column by column with carries.

    1100100 = 100, 110011 = 51; sum 151 = 10010111₂.

    Answer: 151

  2. The byte 00111011 is a signed number in two’s complement. What is its value in decimal?

    Show the working

    Start: If the first bit is 1, subtract 256.

    Leading 0 means positive: 59.

    Answer: 59

  3. What is the hexadecimal number 9A9 in decimal?

    Show the working

    Start: Each place is worth 16 times the next.

    9×16^2 + A×16^1 + 9×16^0 = 2473.

    Answer: 2473

  4. What is this byte in decimal?

    128064032016180402011
    Show the working

    Start: Each box is worth double the one to its right.

    Add the place values with a 1: 16 + 1 = 17.

    Answer: 17

Practise more

New questions every time, at exam level

Add the two binary numbers. What is the answer in decimal?

128064032116181402111+01110010?

Sit a timed SOF ICSO mock test

Next: Logic gates