1 Data Representation - L1 - Introduction To Number System
1 Data Representation - L1 - Introduction To Number System
What is a
computer?
1. Number System
• A numeral system (or system of numeration) is a writing system
for expressing numbers.
• The number (numeral) represents is called its value.
• In digital electronics, the number system is used for representing
the information.
• The number system has different bases and the most common of
them are the decimal, binary, octal, and hexadecimal.
• The base or radix of the number system is the total number of
the digit used in the number system.
Decimal Number Systems
• This number system is known as a decimal
number system because total ten digits are
involved.
• The base of the decimal number system is 10.
Range of Decimal Numbers: 0123456789
Binary Number Systems
• The modern computers do not process decimal number; they work with
binary number system which uses only two digits 0 and1.
• The base of binary number system is 2.
• The range of digits in Binary number system is :
– 0 to (radix -1)
– 0 to (2-1)
– 0 to 1
Tally counting - 8
ON OFF
Decimal system - 8
Binary System - 28 = 256
1 0 1 1 0 0 1 1
28 = 256
0 to 255
Byte = 8 bit
= BIT
BInary digiT
3. Octal Numbers
• The base of the Octal number system is 8.
• The range of digits in the Octal number system is :
– 0 to (radix -1)
– 0 to (8-1)
– 0 to 7
• That is Octal number system is having digit
0, 1, 2, 3, 4, 5, 6, 7
4. Hexadecimal Numbers
• The hexadecimal number system has a base of 16.
• These numbers are used extensively in microprocessor work.
• Range of Hexadecimal Numbers is :
– 0 to (radix -1)
– 0 to (16-1)
– 0 to 15
• The range of digits in Hexadecimal number system
• It consists of the following sixteen number of digits.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
SUMMARY
Decimal Binary Octal Hexadecimal
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
The table is shows the 5 0101 5 5
decimal, binary, octal, 6 0110 6 6
and hexadecimal 7 0111 7 7
numbers from 0 to 15. 8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
02 Number System
How to Convert Decimal to Binary?
• The given decimal number is divided repeatedly by 2 and the remainders are noted down till we get 0 as the
final quotient.
• Step 1: Divide the given decimal number by 2 and note down the remainder.
• Step 2: Now, divide the obtained quotient by 2, and note the remainder again.
• Step 3: Repeat the above steps until you get 0 as the quotient.
• Step 4: Now, write the remainders in such a way that the last remainder is written
first, followed by the rest in the reverse order.
( LSB of the binary number is at the top and the
MSB is at the bottom)
1. Convert the Decimal Number 52 to its binary equivalent.
2. Convert the Decimal Number 151 to its binary equivalent
03 Number System
Descending Powers of Two and Subtraction
1. Start by making a power chart of 2.
2. Look for the greatest power of 2.
3. Move to the next lower power of two.
4. Subtract each successive number that can fit, and
mark it with a 1.
5. Continue until you reach the end of your chart.
6. Write out the binary answer.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
4 Number System
Algorithm
0 0000 0 0
1 0001 1 1
• If the sign bit is “0”, this means the number is positive in value.
• The remaining bits in the number are used to represent the magnitude of the binary number in the usual
unsigned binary number format way.
• Then we can see that the Sign-and-Magnitude (SM) notation stores
positive and negative values by dividing the “n” total bits into two parts:
– 1 bit for the sign and
• n–1 bits for the value which is a pure binary number.
• For example, the decimal number 53 can be expressed as an 8-bit signed binary
number as follows.
Negative Signed Binary Numbers
Positive Signed Binary Numbers
2’s Complement Method
• Please note that MSB is always Sign bit, if it 0, then there are no changes.
• MSB is always 1 in case of negative numbers.
• We only take 2’s complement of negative numbers to represent in the computer.
Text Data Representation
• All alpha-numeric data and special
characters are each assigned a specific
binary value, called a character code.
4 Bits = 1 Nibble or 1 Word
92. Unicode
Character Storage
• ASCII (American Standard Code
for Information Interchange) is a
coding system for representing
characters.
Converting Image to
Binary
10 Image Storage
PIXELS
• To store an image on a computer, the image is first broken
0 for white and 1 for black
down into tiny elements called PIXELS.
• The smallest element in a picture or image is called Pixel
• (in short of Picture Element = Pixel).
• The number of pixels is the product of height and width of
an image
• (In other words, we can say it’s calculated using image
resolution).
• Ex: If your image resolution is 1020 x 800(width x height),
the total number of pixels is 816,000.
Monochrome
• For every pixel, an average color is found and a binary
value is assigned.
Converting Voice to
Binary
12 Audio Storage
12 Audio Storage Representing sound
• Sound needs to be converted into binary for computers to be able to process it.
• To do this, the sound is captured - usually by a microphone - and then converted into a digital signal.
Analogue to Digital converter
• An ADC will sample a sound wave at regular time intervals
Audio sampling
• Audio sampling is the process of transforming a sound source (Analog) into a digital file.
• An analog-to-digital converter will capture a sound wave at regular time intervals. This recording is known as a sound
sample.
Sample rate
• The sampling rate refers to the number of samples of audio recorded every second.
• A higher sample rate provides to deliver a better-quality audio reproduction.
• Common sample rates are 44.1 kHz, 48 kHz, and 96 kHz.
• kHz stands for kilohertz, or 1000 samples per second,
• 44.1 kHz represents 44100 samples per second.
Sample resolution
• Sample resolution is the number of bits used
to represent each sample.
• If more bits are available for each sample,
then more levels of the signal can be
captured, which improves the detail of the
recording.
13 Audio Storage File size reduction
• This is a process where file size is reduced using algorithms resulting in a file that uses fewer storage bits than
the original file.
1. In a situation where one wants to send a picture to her friend, compression will be done at the source device and
decompressed at the destination device. This enables the file to be sent faster, and it reduces overhead traffic for transmitting
the data.
2. In social media apps like WhatsApp, we notice that the image received is of lower quality and consumes much lesser space.
For a few apps, we can set the quality of media to be downloaded.
3. We also notice compression in video streaming sites, where videos are loaded in low quality during poor internet
connectivity.
DATA COMPRESSION
• Data Compression is a technique in which the size of data is reduced without loss of information but at a cost of
lower quality.
• The categories of data compression methods are
1. Lossy compression
2. Lossless compression
• The lossy compression technique does not restored the data in its original form, after decompression.
• The lossless compression restores and rebuilt the data in its original form, after decompression.
Lossy Compression Lossless Compression
(irreversible compression) (reversible compression)
does not eliminate the data which is not
Eliminate the data which is not noticeable.
noticeable.
A file does not restore or rebuilt in its
A file can be restored in its original form.
original form.
Data’s quality is compromised. Does not compromise the data’s quality.
reduces the size of data. does not reduce the size of data.
used in Images, audio, video. used in Text, images, sound.
has more data-holding capacity. has less data-holding capacity
Algorithms used in Lossy compression are: Algorithms used in Lossless compression
Transform coding, Discrete Cosine Transform, are: Run Length Encoding, Lempel-Ziv-
Discrete Wavelet Transform, fractal Welch, Huffman Coding, Arithmetic encoding
compression etc. etc.
Run-length encoding (RLE)
• Run-length encoding (RLE) is a lossless compression method by
specifying the number of times a character or pixel color
repeats followed by the value of the character or pixel.
Follow the steps below is the RLE algorithm:
1. Pick the character from the source string.
2. Count the number of subsequent occurrences of the picked
character and append the count to the destination string.
3. Pick the next character and repeat steps 1, 2 and 3 if the end of the
string is NOT reached.
• For example, if the input string is
“wwwwaaadexxxxxx”