Binary for Integers & Conversions (SQA National 5 Computing Science): Revision Note

Exam code: X816 75

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

Binary to represent positive integers

Why do computers use binary?

  • Computers can only understand two electrical states, on and off

  • These states are represented by 1 and 0 in the binary number system (base 2)

  • All data in a computer is converted into binary before it can be stored or processed

  • Binary is used because it is reliable and efficient, each switch, wire or transistor only needs to handle two possible states

  • Examples

    • 1 = on (electrical current present)

    • 0 = off (no electrical current)

What is denary?

  • Denary (also called decimal) is a number system made up of 10 digits (0–9)

  • It is a base-10 system

  • Each digit has a value based on powers of 10

Column heading

1000

100

10

1

Denary number 3268

3

2

6

8

  • Humans use the denary system for counting, measuring and performing calculations

Diagram showing denary number 3268 with column headings

What is binary?

  • Binary is a number system made up of two digits (1 and 0)

  • It is a base-2 system

  • Each digit has a value based on powers of 2

Column heading

8

4

2

1

Binary number 1100

1

1

0

0

  • Each extra binary digit (bit) doubles the maximum number that can be represented

Diagram showing binary 1101 using binary column headings

8 bit binary column headings

128

64

32

16

8

4

2

1

27

26

25

24

23

22

21

20

Binary to denary conversion

  • To convert binary to denary

    1. Write the column headings for the number of bits

    2. Add together all the headings with a 1 underneath

  • Example 1 (6 bits)

    • Convert binary 101101 to denary

32

16

8

4

2

1

1

0

1

1

0

1

  • (32 + 8 + 4 + 1) = 45

  • Binary 101101 is 45 in denary

  • Example 2 (8 bits)

    • Convert binary 01100011 to denary

128

64

32

16

8

4

2

1

0

1

1

0

0

0

1

1

  • (64 + 32 + 2 + 1) = 99

  • Binary 01100011 is 99 in denary

Examiner Tips and Tricks

  • If a binary number ends in 1, the denary answer must be odd

  • Check that your answer makes sense, a large binary number should give a larger denary result

  • You only need to convert positive integers for SQA National 5

Denary to binary conversion

  • It is important to know how to convert from denary to binary

  • Follow these steps

    1. Write out the binary column headings for 8 bits (128 64 32 16 8 4 2 1)

    2. Find the largest heading smaller than or equal to the denary number

    3. Subtract it, write 1 in that column, and repeat until the remainder is 0

    4. Fill unused columns with 0

  • Example 1

    • Convert the denary number 60 to binary

128

64

32

16

8

4

2

1

0

0

1

1

1

1

0

0

  • Denary 60 is 00111100 in 8-bit binary

  • Example 2

    • Convert the denary number 105 to binary

128

64

32

16

8

4

2

1

0

1

1

0

1

0

0

1

  • Denary 105 is 01101001 in 8-bit binary

Examiner Tips and Tricks

  • Always check how many bits the question asks for

  • If it says “8-bit”, pad your answer with leading zeros

  • Each binary place value doubles as you move left

  • Use subtraction or division by 2, whichever you prefer

Worked Example

(i) Denary to Binary Conversion (8-bit)

A program records a player's score of 79 points.

Convert the denary number 79 into its standard 8-bit binary representation.

[1]

(ii) Binary to Denary Conversion

Convert the following 8-bit binary pattern back into its positive integer (denary) value.

10110010

[1]

Answers

(i)

128

64

32

16

8

4

2

1

0

1

0

0

1

1

1

1

(ii)

  • Denary Value: 178 (Calculation: 128+32+16+2=178)

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Robert Hampton

Author: Robert Hampton

Expertise: Computer Science Content Creator

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.

James Woodhouse

Reviewer: James Woodhouse

Expertise: Computer Science & English Subject Lead

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.