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
- Write the place values, doubling from 1 on the right.
- Write each bit under its place value.
- Add the place values that have a 1 below them.
- To go the other way, subtract the largest place value that fits, and repeat.
Worked example 1: binary to denary
Convert 10110101 to denary.
- Place values: 128 64 32 16 8 4 2 1.
- Bits: 1 0 1 1 0 1 0 1.
- 128 + 32 + 16 + 4 + 1 = 181.
Answer: 181
Worked example 2: denary to binary
Convert 45 to 8-bit binary.
- 45 β 32 = 13, so the 32 bit is 1.
- 13 β 8 = 5, so the 8 bit is 1.
- 5 β 4 = 1, so the 4 bit is 1; then the 1 bit is 1.
- 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?
- Set every bit to 1: 11111111.
- 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.
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 TutorLearn face to face in Glasgow
Prefer in-person lessons? Visit the ExpertTutor Glasgow Southside centre.
See the centre