0% found this document useful (0 votes)
5 views

Lecture 1 - Slide

The document outlines the fundamentals of data representation, covering bits, bytes, and various number systems including binary and hexadecimal. It explains how data is stored and processed in computers, detailing the significance of different data sizes such as kilobytes, megabytes, gigabytes, and terabytes. Additionally, it discusses how different types of data like characters, images, video, and audio are represented using binary and the implications of data compression.

Uploaded by

md6347702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture 1 - Slide

The document outlines the fundamentals of data representation, covering bits, bytes, and various number systems including binary and hexadecimal. It explains how data is stored and processed in computers, detailing the significance of different data sizes such as kilobytes, megabytes, gigabytes, and terabytes. Additionally, it discusses how different types of data like characters, images, video, and audio are represented using binary and the implications of data compression.

Uploaded by

md6347702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Lecture 1

Data Representation
Outline
● Chapter 1: Bits and Bytes
● Chapter 2: Number Systems
● Chapter 3: Bits and Gigabytes
● Chapter 4: Other types of Data - all boils down to
numbers and bits
Chapter 1: Bits and Bytes
1.1 Bit & Byte
1.2 Patterns with N Bits
Bit & Byte

● Computer information is stored at the smallest scale as bits and bytes.

● The "bit" is the fundamental building block for digital information.

● It's the smallest unit for computer data storage and processing.

● A bit, the atomic unit, can be 0 or 1.

● This binary nature is the foundation of the computer language.


Why binary?

● Inside a computer, communication relies on 0's and 1's.

● Binary is the simplest way to represent various data types.

● Anything that can exist in two separate states can serve as a home for a bit.

● Eg. An electric charge on an electronic chip

● Eg. North/South magnetism on a hard drive


Why bother with bits?

● A single bit isn't very useful by itself.

● We group eight bits to form a “byte”, like a small team.

● One byte = collection of 8 bits

● For instance, a byte might look like this: 0 1 0 1 1 0 1 0

● "Byte" - unit of information storage

● One byte can represent a character (a letter, or symbol), e.g. 'A' or 'x' or '$'

● A document, an image, a movie .. how many bytes?


Patterns with N Bits

● 1 bit gives you 2 patterns (0,1).

● 2 bits, and you've got 4 patterns (00, 01, 10, 11).

● 3 bits - 8 patterns (000, 001, 010, 011, 100, 101, 110, 111).

● 4 bits - 16 patterns Question: Can you list the patterns?

● 5 bits - 32, 6 bits - 64, 7 bits - 128. 8 bits - 256 patterns

● For 'N' bits, 2N patterns are possible..


Chapter 2: Number Systems
2.1 Binary Number System
2.2 Hexadecimal Number System
Binary Number System

The binary system uses 1s and 0s only which gives these corresponding weightings:

128 64 32 16 8 4 2 1

27 26 25 24 23 22 21 20

A typical binary number would be:


1 1 1 0 1 1 1 0
Binary to Denary/Decimal

1 1 0 1 (base-2)
1 X 20 = 1
0 X 21 = 0
1 X 22 = 4
1 X 23 = 8
8 + 4 + 0 + 1 = 13
11012= 1310
Decimal to Binary

Successively divide the number by 2:


The remainder from bottom to top to get the
binary number:
2 107

2 53 Remainder: 1 (107)10 = (0 1 1 0 1 0 1 1)2


2 26 Remainder: 1
However, you can also think like this:
2 13 Remainder: 0 What is the largest power of 2 equal or less than 107?
2 6 Remainder: 1 Ans: 64 (so you need 1 at position 6)
What is left? 107 - 64 = 43.
2 3 Remainder: 0
What is the largest power of 2 equal of less
2 1 Remainder: 1 than 43? Ans 32 (you need a 1 at position 5)
2 0 Remainder: 1
What is left? 43-32 = 11
What is the largest power of 2….…and so on
0 Remainder: 0
Hexadecimal Number System

Hexadecimal is a base 16 system with the weightings:

1048576 65536 4096 256 16 1

165 164 163 162 161 160

The numbers 0 - 9 and the letters A - F are used to represent hexadecimal digits.
Hexadecimal Number System
Binary to Hexadecimal

Convert (1 0 1 1 1 1 1 0 0 0 0 1)2 from binary to hexadecimal.

First split it into groups of 4 bits:

1011 1110 0001

Then find the equivalent hexadecimal digits:

B E 1
Hexadecimal to Binary

Convert (45A)16 from hexadecimal to binary.

4 5 A

Find the 4-bit Binary code for each digit:

0100 0101 1010


How to represent a fraction?

In case of fraction, the weights after the decimal point ( . ) will have the following
pattern.

0.5 0.25 0.125 0.0625 0.03125

2-1 2-2 2-3 2-4 2-5


Fractions

What will be the value of (0.111)2 in Decimal?

0.1 1 1 (base-2)
1 X 2-1 = 0.5
0 X 2-2 = 0.25
1 X 2-3 = 0.125
(0.875)10
Fractions
How do we represent 0.3 in Binary?

0.3 X 2 = 0 .60
● Start with 0.3 and multiply with 2.
● Take the fractional part of the result and
0.6 X 2 = 1 .20 multiply it with 2 again.
● Keep doing it until … ?
0.2 X 2 = 0 .40
● We do have memory constraints so can’t
0.4 X 2 = 0 .80 continue indefinitely.
● The closest we can get is:
0.8 X 2 = 0 .60 ○ (0.01010)2 = (0.3125)10
○ (0.010001)2 = (0.28125)10
0.6 X 2 = 1 .20
● Which one is better? Why?
. . . . ● IEEE754: commonly used standard for
representing floating/real numbers in
computer.
Absolute and relative error

Absolute Error:
● Discrepancy between the measured and true values.
● Example: 1 cm error in height measurement.
Relative Error:
● Measures the error relative to the true value.

● Example: Comparing errors in your height and ant length measurements.


Question:
● What is the relative error in representing the number 0.3 discussed in previous
slide?
Chapter 3: Bits and Gigabytes
3.1 Kilobyte
3.2 Megabyte
3.3 Gigabyte
3.4 Terabyte
3.5 Gigahertz - Speed, not Bytes
Kilobyte

● Kilobyte KB = 210 bytes = 1024 bytes approximately 103 bytes

● 1 byte is one typed character

● A five page paper might be 100 KB

● 23,000 bytes is about 23 KB


Megabyte

● Megabyte, MB (220 = 1048576 bytes), about 1 million (106) bytes

● MP3 audio is about 1 megabyte per minute

● A high quality digital picture is about 2-5 megabytes

● Audio, image and video data typically stored in "compressed" form, e.g. MP3.

● The audio on a CD is not compressed, hence takes more space than MP3.

● Data on the disk is encoded using tiny pits in a spiral pattern.

● Where pits represent 0 and the absence of pits represents 1.


Gigabyte

● Gigabyte, GB (230 bytes), about 1 billion (109) bytes

● GB is a common unit for modern hardware, e.g. 4000 MB = 4 GB.

● An ordinary computer might have:

○ - 4 GB or RAM

○ - 256 GB of persistent storage

● A DVD disk has a capacity 4.7GB (single layer)

● A flash drive might hold 32 GB


Terabyte

● Terabyte, TB (240 bytes), about 1 trillion (1012) bytes

● Nowadays, computer hard drives can have storage capacities of 1-2 terabytes (TB).

● Petabytes, PB (250 bytes), about 1 quadrillion (1015) bytes

○ Large scale scientific experiments like particle accelerators in CERN generate

data in this scale


Gigahertz - Speed, not Bytes

● One gigahertz is 1 billion cycles per second.

● A megahertz is a million cycles per second.

● Gigahertz is a measure of speed.

● The rate that a CPU can do its simplest operation per second.

● Gigahertz serves as a rough indicator of CPU speed, though not precise.

● Higher gigahertz CPUs consume more power, and generate increased heat.

● ARM produces efficient, low-power chips for mobile phones.


Chapter 4: Other types of Data - all
boils down to numbers and bits
4.1 Characters
4.2 Digital Images
4.3 Video
4.4 Audio/Sound
Characters
● ASCII, which stands for
American Standard Code for
Information Interchange, is
one such encoding system
● each character using a unique
number, and remarkably,
each of these numbers fits
neatly into one byte, ranging
from 0 to 255.
Unicode
● Multilingual Support: Unicode is designed to represent characters from
virtually every language in the world.
● Variable Length Encoding: Unicode uses variable-length encoding, allowing it to
accommodate a vast number of characters. While some characters are
represented with a single 16-bit unit (known as a "code unit"), others may use a
pair of 16-bit units for more complex characters.
● Standardization and Adoption: Unicode is developed and maintained by the
Unicode Consortium, a non-profit organization that ensures continuous updates
and additions to the standard.
● Emoji: Unicode includes a set of characters for emojis
Text documents

A string is a sequence of characters

A text file basically holds a sequence of characters all represented by the ASCII /
Unicode based numbers.
Images

An image of size 800 x 600 A part of the flower 10x Zoomed


Image pixels
RGB

The color of each pixel is described


using three numbers – one for red, one
for green, and one for blue.

These numbers can take values


between 0 and 255 (8bits)
Question

How much memory do you need to store a 500 x 500 pixel color image, if it is not
compressed in any way?

[note images are usually compressed in someway]


Video
● Most digital cameras, smartphones and tablets are capable of taking moving
images by ‘stitching’ a number of still photos (frames) together.
● Frame rate is the number of frames (or still images) it captures per second.
○ In movies the frame rate is typically 24 frames per second (fps)
○ In HDTVs the frame rate is typically 60Hz or 120Hz
○ When viewing movies shot in 24fps on HDTVs, the tv will try to do
something called Motion Interpolation automatically so that the frame rate
is 60/120 or more.
○ This actually makes the look of the movies a bit strange
○ You can actually turn this off and enjoy movies as the movie directors
intended.
Question

How much memory do you need to store 1 minute color video shot with 60 fps?
Assume (the image size is 500 x 500)

[note videos are usually compressed in someway]


Audio Audio signals are sampled
at fixed intervals - sampling
rate (say 44K Hz)
The amplitude of the signal
are converted into numbers
However , fixed number of
bits are used to represent
the numbers (bit
rate/depth) so number are
approximately represented

In the above figure a list of 20 numbers will be used to approximately represent


the signal [9, 4, …, 7] and there numbers will eventually be stored in binary (here
we will need at least 4 bits as the numbers are always between 0 - 10
Question

If a sampling rate of 44 KHz (44K samples per second) is used with 128-bit rate (or sampling
resolution), how much storage will be required to store a typical Bangla song?

[note images are usually compressed in someway]


Time series data
Audio signals are examples of Time Series data.

Time series generally applies to any data where some quantity (sound amplitude for Audio)
is stored at different times.

Hourly temperature of a city over 50 hours


Time series
Typical analysis includes Trend analysis

Examples of time series data include:

● Weather data
● Rainfall measurements
● Heart rate monitoring (EKG)
● Brain monitoring (EEG)
● Quarterly sales
● Stock prices
● Automated stock trading
● Industry forecasts
● Interest rates
Question: what trend do you see here?

This is the time series of number of


miles traveled by vehicles in the US per
month, between January 2000 and
December 2014.
Thank you

You might also like