COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
HOME    >    GCSE    >   CAMBRIDGE EXAMINATIONS    >    BINARY SHIFTS
NEXT PAGE >
NEGATIVE NUMBERS
Picture

DATA REPRESENTATION - 1.1.5 | BINARY SHIFT

Topics from the Cambridge IGCSE (9-1) Computer Science 0984 syllabus 2023 - 2025.
OBJECTIVES
1.1.5 Perform a logical binary shift on a positive 8-bit binary integer and understand the effect this has on the positive binary integer
  • LEARN
  • TERMINOLOGY
  • QUESTIONS
  • FLASHCARDS
  • WORKBOOK
<
>
Picture

we’re going to learn about binary shifts. Binary shifts are an essential concept in computing, used to move the position of binary digits left or right. Shifting changes the value of a binary number, either making it larger or smaller. Let’s dive in! Part 1: What is a Binary Shift? In binary, each place represents a power of two. So when we shift a binary number, we’re actually multiplying or dividing it by powers of two. Shifting can happen in two directions: left and right. Part 2: Left Shift Let’s start with the left shift. A left shift moves all the digits in a binary number one or more places to the left. When we do this, we add zeros to the right end of the number to fill in the empty spaces. Here’s the rule for a left shift: Each time we shift left by one place, it’s like multiplying the number by 2. Let’s look at an example. Suppose we have the binary number 1 0 1 0, which is 10 in decimal. If we shift 1 0 1 0 one place to the left, it becomes 1 0 1 0 0. Now, in decimal, 1 0 1 0 0 equals 20. So, we doubled the original value. If we shift 1 0 1 0 two places to the left, it becomes 1 0 1 0 0 0. In decimal, 1 0 1 0 0 0 is 40, which is twice as large as the result from one left shift. So, remember: each left shift doubles the value. Part 3: Right Shift Now, let’s look at the right shift. A right shift moves all the digits in a binary number one or more places to the right. When we shift right, we lose the digits on the far right and add zeros on the left to fill in the gaps. Here’s the rule for a right shift: Each time we shift right by one place, it’s like dividing the number by 2. Let’s use our example again. We’ll start with the binary number 1 0 1 0, or 10 in decimal. If we shift 1 0 1 0 one place to the right, it becomes 1 0 1. In decimal, 1 0 1 is 5. So, we’ve divided the original value by 2. If we shift 1 0 1 0 two places to the right, it becomes 1 0. In decimal, 1 0 is 2, which is half of the result from one right shift. So, each right shift divides the value by 2. Part 4: Summary To summarize: Left shifts multiply the number by 2 for each place shifted. Right shifts divide the number by 2 for each place shifted. Binary shifts are powerful tools in computing, especially for optimizing calculations. By shifting, we can quickly multiply or divide values without complicated operations. And that’s binary shifts in a nutshell! Thanks for listening, and I hope this helps you understand how left and right shifts work in binary numbers.

Read Aloud
■
WHAT IS A BINARY SHIFT
Performing a logical binary shift on a positive 8-bit binary integer involves shifting all the bits in the binary number to the left or right by a specified number of positions. The shift can be either a left shift, which involves moving all the bits to the left and adding 0's on the right, or a right shift, which involves moving all the bits to the right and adding 0's on the left.

The effect of a logical binary shift on a positive binary integer depends on the direction and the number of bit positions being shifted. In a left shift, the value of the binary number is effectively multiplied by 2 to the power of the number of bit positions being shifted. This is because each bit in the binary number represents a power of 2, and shifting the bits to the left increases the value of the number by a factor of 2. Conversely, in a right shift, the value of the binary number is effectively divided by 2 to the power of the number of bit positions being shifted. This is because shifting the bits to the right decreases the value of the number by a factor of 2.

For example, let's consider the binary number 00011010. If we perform a left shift by 2 positions, we get 01101000. This is equivalent to multiplying the original value (26 in denary) by 2^2, which gives us 104 in denary. On the other hand, if we perform a right shift by 3 positions, we get 00000011. This is equivalent to dividing the original value (26 in denary) by 2^3, which gives us 3 in denary.

This operation is commonly used in digital systems and programming languages to perform efficient arithmetic and data manipulation operations on binary data.
HOW TO PERFORM A BINARY SHIFT
Here are two example tables showing the the process of a binary shift and the outcome of each.
Picture
Table 1: Before Logical Binary Shift
Picture
Table 2: After Logical Binary Shift (Left Shift by 2 Positions)
​In this example, we have a binary number represented in an 8-bit format with the values of each bit position indicated in the column headers. The original binary number is 10110010 (178 in denary), which is represented in the first row of Table 1. We want to perform a left shift by 2 positions, which involves moving all the bits to the left and adding 0's on the right. The resulting binary number is 11001000 (200 in denary), which is represented in the first row of Table 2.
Picture
Table 3: Before Logical Binary Shift
Picture
Table 4: After Logical Binary Shift (Right Shift by 3 Positions)
​In this example, we have the same binary number represented in Table 3, which is 10110010 (178 in denary). We want to perform a right shift by 3 positions, which involves moving all the bits to the right and adding 0's on the left. The resulting binary number is 00001011 (11 in denary), which is represented in the first row of Table 4.
CHECK YOUR KNOWLEDGE

What is the result of performing a left shift by one place on the binary number 0011?

A) 00110
B) 0110
C) 1100
D) 1110
EXPLAINATION
The correct answer is C) 1100.
When you perform a left shift on the binary number 0011 by one place, it becomes 1100. This left shift effectively multiplies the original value by 2, which is a key characteristic of left shifts in binary.
.
Binary | A base-2 number system used in computing that includes only two digits: 0 and 1.
Bit | The smallest unit of data in computing, represented as either 0 or 1.
Binary Shift | A method of moving the positions of binary digits either to the left or right, affecting the value of the binary number.
Left Shift | A binary shift where each digit is moved one or more places to the left, effectively multiplying the binary number by 2 for each place shifted.
Right Shift | A binary shift where each digit is moved one or more places to the right, effectively dividing the binary number by 2 for each place shifted.
Place Value | The value of a position in a binary number, each representing a power of 2, increasing from right to left.
Multiplication by Powers of 2 | The effect of a left shift, where the value of a binary number doubles with each left shift position.
Division by Powers of 2 | The effect of a right shift, where the value of a binary number halves with each right shift position.
Padding | The process of adding zeros to the right (in a left shift) or to the left (in a right shift) to maintain the binary structure after shifting.
Overflow in Shifting | Occurs when a left shift pushes bits beyond the register’s capacity, causing data to be lost.
Logical Shift | A type of binary shift that simply moves all bits left or right and inserts a 0 at the vacant positions, with no consideration for the sign of the number.

​Arithmetic Shift | 
A binary shift typically used with signed numbers; it shifts the bits while maintaining the sign bit (the leftmost bit) in a right shift.
Picture
1: What is a logical binary shift?
A) A type of sorting algorithm
B) A way of converting binary to denary
C) A method of manipulating binary numbers by shifting the bits left or right
D) A way of compressing digital images

2: What happens to a binary number when it is shifted left by one position?
A) The value is multiplied by 2
B) The value is divided by 2
C) The value is shifted right by one position
D) The value remains the same

3: What happens to a binary number when it is shifted right by one position?

A) The value is multiplied by 2
B) The value is divided by 2
C) The value is shifted left by one position
D) The value remains the same

4: Which of the following is a common use case for logical binary shifts in computer programming?
A) Sorting data in a database
B) Encrypting sensitive data
C) Manipulating binary data efficiently
D) Generating random numbers

5: What is the effect of a logical binary shift on the size of a binary number?
A) It always increases the size of the binary number
B) It always decreases the size of the binary number
C) It can increase or decrease the size of the binary number, depending on the direction and number of positions being shifted
D) It has no effect on the size of the binary number

6: If the binary value 110110 is shifted left by two positions, what is the resulting binary value?
A) 000011
B) 101101
C) 011011
D) 011000

7: If the binary value 10010010 is shifted right by three positions, what is the resulting binary value?
A) 00010010
B) 00010001
C) 10000100
D) 01001000
Picture
NEXT PAGE | NEGATIVE NUMBER REPRESETATION
1.1 NUMBER SYSTEMS
   
☑ 1.1.1 WHY COMPUTERS USE BINARY
    ☑ 1.1.2 BINARY, HEX AND CONVERTIG BETWEEN NUMBER SYSTEMS
    ☑ 1.1.3 BENEFITS OF HEX
    ☑ 1.1.4 BINARY ADDITION AND OVERFLOW
    ➩ 1.1.5 BINARY SHIFTS
    ☐ 1.1.6 NEGATIVE NUMBER REPRESENTATION, TWO'S COMPLEMENT
1.2 COLOUR AND SOUND

    ☐ 1.2.1 HOW COMPUTERS REPRESENT TEX
    ☐ 1.2.2 HOW COMPUTERS REPRESENT SOUND
    ☐ 1.2.3 HOW COMPUTERS REPRESENT IMAGES
1.3 FILE SIZE AND COMPRESSION

    ☐ 1.3.1 HOW STORAGE IS MEASURED
    
☐ ​1.3.2 CALCULATING IMAGE AND SOUND FILE SIZE
   
☐ ​1.3.3 PURPOSE OF COMPRESSION
   
☐ ​1.3.4 LOSSY AND LOSSLESS COMPRESSION
 EXTRAS

    ☐ END OF TOPIC REVIEW | COMING SOON
    
☐ TOPIC 1 KEY TERMINOLOGY
    
☐ REVISION FLIP CARDS
    
☐ TOPIC 1 ANSWERS
    
☐ TOPIC 1 TEACHER RESOURCES (CIE)
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.