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    >    IMAGE & SOUND FILE SIZE
NEXT PAGE >
PURPOSE OF COMPRESSION
Picture

1.3.2 | CALCULATING FILE SIZE

Topics from the Cambridge IGCSE (9-1) Computer Science 0984 syllabus 2023 - 2025.
OBJECTIVES
​1.3.2 Calculate the file size of an image file and a sound file, using information given
  • LEARN
  • TERMINOLOGY
  • QUESTIONS
  • FLASHCARDS
  • WORKBOOK
<
>
Picture

we’re going to dive into three ways to represent positive and negative numbers in binary: Sign and Magnitude, One’s Complement, and Two’s Complement. Let’s break down each method and see how they work. Part 1: Sign and Magnitude Let’s start with Sign and Magnitude. This is one of the simplest ways to represent positive and negative numbers in binary. Here’s how it works: In Sign and Magnitude, we use the leftmost bit – known as the sign bit – to indicate whether the number is positive or negative: If the sign bit is 0, the number is positive. If the sign bit is 1, the number is negative. The remaining bits represent the actual value, or magnitude. For example: In an 8-bit system, the binary number 0000 1010 has a sign bit of 0, meaning it’s positive. The remaining bits, 0000 1010, represent the number 10 in decimal. Now, if we change that sign bit to 1, making it 1000 1010, the number becomes -10 in decimal. The rest of the bits stay the same, representing the value. However, Sign and Magnitude has limitations because it can make binary arithmetic more complex, especially when dealing with subtraction. Part 2: One’s Complement Next, we have One’s Complement. This method also uses the leftmost bit as a sign bit, but it represents negative numbers differently. Here’s the rule for One’s Complement: To find the One’s Complement of a binary number, invert all the bits – that means changing 0s to 1s and 1s to 0s. For example: If we want to represent -10 in an 8-bit system: Start with the positive binary representation of 10, which is 0000 1010. Invert each bit to get the One’s Complement: 1111 0101. So, 1111 0101 represents -10 in One’s Complement. One’s Complement simplifies some operations, but there’s a problem: it has two representations of zero. 0000 0000 represents positive zero, and 1111 1111 represents negative zero, which can make arithmetic operations tricky. Part 3: Two’s Complement Finally, let’s look at Two’s Complement. This is the most widely used method because it solves the issue of having two zeros and makes binary arithmetic easier. Here’s how to find the Two’s Complement of a number: Start with the positive version of the number in binary. Invert all the bits to get the One’s Complement. Add 1 to the result. For example: Let’s represent -10 in Two’s Complement. Start with the positive version of 10 in binary: 0000 1010. Invert all the bits to get 1111 0101. Add 1 to the inverted result: 1111 0101 + 1 = 1111 0110. So, 1111 0110 represents -10 in Two’s Complement. Two’s Complement only has one representation of zero, which is 0000 0000. It also makes addition and subtraction much simpler for computers because they can treat both positive and negative numbers the same way during calculations. Part 4: Summary To recap: Sign and Magnitude uses a sign bit to indicate positive or negative, but it can make arithmetic tricky. One’s Complement inverts all the bits to represent negative numbers, but it has two zeros. Two’s Complement inverts all the bits and adds 1, making binary arithmetic easier and solving the two-zero issue. And that’s it! These three methods – Sign and Magnitude, One’s Complement, and Two’s Complement – are fundamental to understanding how computers represent both positive and negative numbers in binary. Thanks for listening, and I hope this explanation helps you see how each method works!

Read Aloud
■
CALCULATING IMAGE FILE SIZE
Picture
IMAGE 1 : 8 x 8 pixels
Picture
IMAGE 2 : 16 x 16 pixels
To calculate the file size of the two images above, firstly although only two colours have been used, lets presume a colour depth of 8 bit for both images.
Image 1 calculation:
Firstly; calculate the total amount of pixels used in the image
8 pixels wide by 8 pixels tall:  8 x 8 = 64 (A total of 64 pixels used to represent the entire image)
Secondly; multiply the total pixels used by the colour depth (8 bits have been used to represent the content of each pixel)
64 pixels in total multiplied by 8(colour depth): 64 x 8 = 512
Answer: 
Image 1 has a file size of 512 bits

Image 2 calculation: 
16 pixel by 16 pixels: 16 x 16 = 256
256 pixels x 8 bit colour depth: 256 x 8 = 2048
Answer: Image 2 has a file size of 2048 bits

In practise images are much larges and the pixel density is much greater than the two example above.
Picture
IMAGE 3: Dimensions 1600 pixels x 1200 pixels : Bit Depth 24
Follow the same steps to calculate the file size of image 3, this time convert the file size from bits too Megabytes.
Step 1: Multiply the number of horizontal pixels by the number of vertical pixels: 1600 x 1200 = 1920000 pixels
Step 2: 
Multiply the total pixels used by the colour/bit depth: 1920000 x 24 = 46080000 bits
Step 3: 
Divide the answer from step 2 by 8 to give the number of bytes used: 46080000 / 8 = 5760000 bytes
Step 4: 
Divide the number of bytes used by 1024 to give the value in Kilobytes: 5760000 / 1024 = 5625 Kilobytes
Step 5:  Divide the number of kilobytes used by 1024 to give the value in Megabytes: 5625 / 1024 = 5.4 Megabytes
​

The original image 3 has a file size of 5.2Mb, this value excludes any metadata storage used and was the file size before being compressed for use over the internet
CHECK YOUR KNOWLEDGE

What is the two's complement representation of -5 in an 8-bit binary system?

A) 1111 1011
B) 1111 1101
C) 1000 0101
D) 1111 1001
.
Picture
IMAGE SIZE
1: An image has the following properties:
  • Dimensions 1024 pixels x 575 pixels
  • Bit Depth 24
Calculate the image size, show your workings at each stage and display the result in Mb.

2: An image has the following properties:
  • Dimensions 12 inch x 11 inch
  • Bit Depth 16
  • 72 pixels per inch
Calculate the image size, show your workings at each stage and display the result in Mb.

3: Besides the size and bit depth of an image, what else could have an impact on the total file size?

4:Give two situation where reducing the file size of an image is needed, explain the impact of doing this.
Picture
NEXT PAGE | CALCULATIONG FILE SIZE
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 TEXT
    ☑ 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.