2210 Computer Science
BSS CSBC, Lahore
Data Representation – Calculate a File Size
Learning Outcomes:
• Students will understand how data storage is measured.
• Calculate the file size of an image file & Sound file, using information given.
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 1
Data Representation – Calculation a File Size
File Size
- The amount of digital storage space that a file occupies on a storage device.
- A bit is the basic unit of all computing memory storage terms and is either 1 or 0. The
word comes from binary digit.
- The byte is the smallest unit of memory in a computer.
1 byte is 8 bits.
- A 4-bit number is called a nibble - half a byte.
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 2
Data Representation – Calculation a File Size
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 3
Data Representation – Calculation a File Size
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 4
Data Representation – Calculation a File Size
‐ In this section we will look at the calculation of the file size required to hold a bitmap image
and a sound sample.
‐ The file size of an image is calculated as:
image resolution (in pixels) x colour depth (in bits)
‐ The size of a mono sound file is calculated as:
sample rate (in Hz) × sample resolution (in bits) x length of sample (in seconds)
‐ For a stereo sound file, you would then multiply the result by two.
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 5
Data Representation – Calculation a File Size
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 6
Data Representation – Calculation a File Size
‐ A photograph is 1024 × 1080 pixels and uses a colour depth of 32 bits. How many photographs
of this size would fit onto a memory stick of 64 GiB?
‐ Multiply number of pixels in vertical and horizontal directions
to find total number of pixels = (1024 × 1080) = 1105920 pixels
‐ Now multiply number of pixels by colour depth then divide by 8 to give the
number of bytes = 1105920 × 32 = 35389440/8 bytes = 4423680 bytes
64 GiB = 64 × 1024 × 1024 × 1024 = 68719476736 bytes
‐ Finally divide the memory stick size by the files size = 68719476736 / 4423680 = 15534photos.
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 7
Data Representation – Calculation a File Size
‐ A digital camera has an array of 2048 by 2048 pixels and uses a colour depth of 16. Find the size
of an image taken by this camera in MiB.
‐ Multiply number of pixels in vertical and horizontal directions
to find total number of pixels = (2048 × 2048) = 4194304 pixels
‐ Now multiply number of pixels by colour depth = 4194304 × 16 = 67108864 bits
‐ Now divide number of bits by 8 to find the number of bytes in the file
= 67108864/8 = 8388608 bytes
‐ 4. Now divide by 1024 × 1024 to convert to MiB = 8388608 / 1048576 = 8 MiB.
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 8
Data Representation – Calculation a File Size
‐ An audio CD has a sample rate of 44100 and a sample resolution of 16 bits. The music being
sampled uses two channels to allow for stereo recording. Calculate the file size for a 60-minute
recording.
‐ Size of file = sample rate (in Hz) × sample resolution (in bits) × length of sample
‐ Size of sample = (44100 × 16 × (60 × 60)) = 2540160000bits
‐ Multiply by 2 since there are two channels being used = 5080320000
‐ Divide by 8 to find number of bytes = 5080320000/8 = 635040000
‐ Divide by 1024 × 1024 to convert to MiB = 635 040 000 / 1 048 576 = 605Mib
Thursday, July 10, 2025 M.Nouman Arif (Computer Science) BSS - CSBC 9