Homeβ€ΊStudy Resourcesβ€ΊComputer Scienceβ€Ί
How do you convert a binary number to denary?
Computer Science
National 5

How do you convert a binary number to denary?

To convert binary to denary, write the place values above each bit. For 8 bits these are 128, 64, 32, 16, 8, 4, 2 and 1. Add the place values that have a 1 below them. National 5 Computing Science uses binary to represent positive integers. Example: Convert 10110101 to denary. Place values: 128 64 32 16 8 4 2 1 Bits: 1 0 1 1 0 1 0 1 Add: 128 + 32 + 16 + 4 + 1 Answer: 181

Quick answer: Write the place values (128, 64, 32, 16, 8, 4, 2, 1 for 8 bits) above the bits, then add the place values that sit above a 1.

What the specification expects

Data representation is in Computer systems in the SQA National 5 Computing Science course specification. You need to:

  • describe and exemplify the use of binary to represent positive integers
  • convert from binary to denary and vice versa

Method

  1. Write the place values, doubling from 1 on the right.
  2. Write each bit under its place value.
  3. Add the place values that have a 1 below them.
  4. To go the other way, subtract the largest place value that fits, and repeat.

Worked example 1: binary to denary

Convert 10110101 to denary.

  1. Place values: 128 64 32 16 8 4 2 1.
  2. Bits: 1 0 1 1 0 1 0 1.
  3. 128 + 32 + 16 + 4 + 1 = 181.

Answer: 181

Worked example 2: denary to binary

Convert 45 to 8-bit binary.

  1. 45 βˆ’ 32 = 13, so the 32 bit is 1.
  2. 13 βˆ’ 8 = 5, so the 8 bit is 1.
  3. 5 βˆ’ 4 = 1, so the 4 bit is 1; then the 1 bit is 1.
  4. Fill the other places with 0.

Answer: 00101101

Worked example 3: largest 8-bit value

What is the largest positive integer 8 bits can store?

  1. Set every bit to 1: 11111111.
  2. 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.

Answer: 255

Common mistakes

  • Writing the place values in the wrong order. The largest is on the left.
  • Adding place values under a 0.
  • Leaving out leading zeros when an 8-bit answer is asked for.

FAQs

Why do computers use binary?

Computers store data as two states, so binary (0 and 1) is used to represent numbers.

Does National 5 include negative numbers?

No. National 5 covers positive integers. Two's complement for negative numbers is a Higher topic.

Want one-to-one help? Find an online Computer Science tutor with ExpertTutor.

Reviewed by

Want one-to-one support?

One-to-one online tuition can help you build confidence in your subject. Find a tutor who teaches your course.

Find a Tutor

Learn face to face in Glasgow

Prefer in-person lessons? Visit the ExpertTutor Glasgow Southside centre.

See the centre