Lect - 05 C Binary System
Lect - 05 C Binary System
EHB 328E
Ibraheem Shayea
Electronics and Communication Engineering Department,
Faculty of Electrical and Electronics Engineering
İstanbul Teknik Üniversitesi - İTÜ
Syllabus 5
Binary System
Part C
Outline
❑ Binary System
❑ Simplicity
Binary representation is simple and easy to implement in hardware
and software. Using only two digits makes it easier to design circuits
and algorithms that can process and manipulate data.
Important of Binary System
Why Data Representation in Binary Form?
❑ Compatibility
For Example:
o Numbers is converted from decimal to binary numbers, 0s and 1s.
o ..etc
Important of Binary System
Why Data Representation in Binary Form?
Thus
❑ Binary System has only two digits (0 and 1), thus computer circuits
only have to handle two binary digits
❑ Bytes is used as a measure unit for file sizes and storage capacities.
o Kilo Bytes ➔ kB,
o Giga Bytes ➔ GB
i.e. file size is 200 kB, Driver Size 80GB, 500GB, 1TB,.. etc
Binary System
Byte
Name Abbr. Size
Bit bit One binary digit
Byte B 8 bits
Kilo Byte K 𝟐𝟏𝟎 = 1,024 Byte
Mega Byte M 𝟐𝟐𝟎 = 1,048,576 Byte
Giga Byte G 𝟐𝟑𝟎 = 1,073,741,824 Byte
Tera Byte T 𝟐𝟒𝟎 = 1,099,511,627,776 Byte
Peta Byte P 𝟐𝟓𝟎 = 1,125,899,906,842,624 Byte
Exa Byte E 𝟐𝟔𝟎 = 1,152,921,504,606,846,976 Byte
Zetta Byte Z 𝟐𝟕𝟎 = 1,180,591,620,717,411,303,424 Byte
Yotta Byte Y 𝟐𝟖𝟎 = 1,208,925,819,614,629,174,706,176 Byte
Binary System
Byte
Name Abbr. Size
Bit bit One binary digit
Byte B 8 bits
Kilo Byte K 𝟐𝟏𝟎 = 1,024 Byte x 8 bits
Mega
M 𝟐𝟐𝟎 = 1,048,576 Byte x 8 bits
Byte
Giga Byte G 𝟐𝟑𝟎 = 1,073,741,824 Byte x 8 bits
Tera Byte T 𝟐𝟒𝟎 = 1,099,511,627,776 Byte x 8 bits
Peta Byte P 𝟐𝟓𝟎 = 1,125,899,906,842,624 Byte x 8 bits
Exa Byte E 𝟐𝟔𝟎 = 1,152,921,504,606,846,976 Byte x 8 bits
Zetta Byte Z 𝟐𝟕𝟎 = 1,180,591,620,717,411,303,424 Byte x 8 bits
Yotta Byte Y 𝟐𝟖𝟎 = 1,208,925,819,614,629,174,706,176 Byte x 8 bits
Numbers in Binary System
Numbers in Binary System
Numbers in Binary form
❑ Numeric Data consists of numbers DECIMAL (BASE 10) BINARY (BASE 2)
operations. 1 1
2 10
3 11
❑ Digital Devices represent numeric 4 100
data using the binary number system. 5 101
6 110
7 111
❑ Number of Digits: In binary
8 1000
representation, numbers are
9 1001
represented using only two digits: 0
and 1. 10 1010
Numbers in Binary System
Value of Each Binary Digit
Example
1 0 1 0
• 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20
• = 8 + 0 + 2 + 0
• = 10 (in decimal)
Numbers in Binary System
Numbering Systems
There are various Numbering Systems Used in Computer and
Electronic Devices
A. Binary Number System
1101
o 13 / 2 = 6, remainder 1
o 6 / 2 = 3, remainder 0
o 3 / 2 = 1, remainder 1
o 1 / 2 = 0, remainder 1
Base 2 representation 27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
Decimal representation
0 0 1 0 0 0 1 1
Base 2 representation
𝟎 × 𝟏𝟐𝟖 +
𝟎 × 𝟔𝟒 +
𝟏 × 𝟑𝟐 +
0 0 1 0 0 0 1 1 𝟎 × 𝟏𝟔 + Decimal 35 = 00100011
𝟎×𝟖 +
𝟎×𝟒 +
𝟏×𝟐 +
𝟏×𝟏
= 𝟑𝟓
Numbers in Binary System
Convert Decimal to Binary Number
Example:
Convert the 145 Decimal Number into Binary bit stream?
Answer:
?
Numbers in Binary System
Convert Binary to Decimal Number
Example:
Convert the 145 Decimal Number into Binary bit stream?
Answer:
Base 2 representation 27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
Decimal representation
1 0 0 1 0 0 0 1
Base 2 representation
𝟏 × 𝟏𝟐𝟖 + 𝟎 × 𝟔𝟒 + 𝟎 × 𝟑𝟐 + 𝟏 × 𝟏𝟔 + 𝟎 × 𝟖 + 𝟎 × 𝟒 + 𝟎 × 𝟐 + 𝟏 × 𝟏
= 𝟏𝟒𝟓𝟏𝟎
Numbers in Binary System
Convert Binary to Decimal Number
𝑩𝒊𝒕 𝑿 𝟐𝒌
Numbers in Binary System
Convert Binary to Decimal Number
Example:
Convert the bit stream of 11010010 to a Decimal Number?
Answer:
?
Numbers in Binary System
Convert Binary to Decimal Number
Example:
For example: 110100102 = 1*128 + 1*64 + 0*32 + 1*16 + 0*8 + 0*4 + 1*2 +0*1 = 21010
Numbers in Binary System
Convert Binary to Decimal Number
Example:
Convert the bit stream of 10101110 to a Decimal Number?
Answer:
?
Numbers in Binary System
Convert Binary to Decimal Number
Example:
Convert the bit stream of 10101110 to a Decimal Number?
Answer:
Binary 1 0 1 0 1 1 1 0
Position 8TH 7TH 6TH 5TH 4TH 3RD 2ND 1ST
Base 2 Representation 27 26 25 24 23 22 21 20
Decimal Representation 128 64 32 16 8 4 2 1
Octal Digit 0 1 2 3 4 5 6 7
Binary 000 001 010 011 100 101 110 111
Let’s convert the octal numbers 25 and 140.
2 5 1 4 0
010 101 001 100 000
Numbers in Binary System
Convert Binary to Octal Number
Conversion of a binary number to an octal number is the reverse of the octal-to-binary
conversion.
A binary number can be converted into an equivalent octal number by splitting the
integer and fractional parts into groups of three bits, starting from the binary point on
both sides. The 0s can be added to complete the outside groups if needed.
Example:
Let’s convert the following binary numbers to octal:
Example 1 :
110 101
6 5 = 65
Example 2 :
101111001
Numbers in Binary System
Convert Hexadecimal to Binary Number
❑ A hexadecimal number can be converted into its binary equivalent by
replacing each hex digit with its four-bit binary equivalent.
o 0+0=0;
o 0+1=1;
o 1 + 0 = 1;
o 1 + 1 = 10
Numbers in Binary System
Subtraction in Binary System
o 0-0=0
o 0-1=?
o 1-0=1
o 1-1=0
Text in Binary System
Text in Binary System
Representing Text in Binary Systems
❑ Digital File
A digital file, usually referred to simply as a file, is a named collection of data that
exits on a storage medium, such as a hard disk, CD, DVD, or flash drive.
Text in Binary System
Digital Files
❑ DOCX format : Microsoft Word produces
formatted text and creates documents in
DOCX format.
o Numbers from 0 to 9
Step 1. Step 2.
Presses the capital An electronic signal for the
letter D on the capital letter D is sent to the
keyboard. system unit.
Step 3.
Step 4.
The signal for the capital letter D is
After processing, the binary code for the
converted to its ASCII binary code
capital letter D is converted to an image,
(01000100) and is stored in memory
and displayed on the output device.
for processing.
Text in Binary System
Methods of Representing Character
Digital Devices employ several types of codes to represent character
data. The most three popular coding Methods to represent data are:
❑ Unicode
o Coding scheme capable of representing all world’s languages
❑ ASCII
❑ EBCDIC
00110000 0 11110000
00110001 1 11110001
00110010 2 11110010
00110011 3 11110011
Text in Binary System
ASCII
❑ ASCII: American Standard Code for Information
Interexchange
▪ ASCII−7
▪ ASCII−8
Text in Binary System
ASCII
ASCII-7
ASCII-7 is a 7-bit standard ASCII code.
❖ ASCII-8 is an 8-bit code having 4 bits for zone and 4 bits for the digit.
1. Get Character.
o What is the size of Design and Communications Graphics in Bytes and bits?
Answer:
o B41 is 3 Bytes long
?
Text in Binary System
Binary Coding Schemes (Methods)
Character in Binary System
ASCII-8
Data Steam
Text in Binary System
Exercise
Utilizing ASCII/UTF-8 :
A.What is the size of “Hello, How are you? ” in Bytes and bits?
B. Covert the following sentence “Hello, How are you? ” to a Binary Code?
???
Text in Binary System
Exercise
Utilizing ASCII/UTF-8 :
A.What is the size of “Hello, How are you? ” in Bytes and bits?
Answer:
This is the binary representation of the sentence "Hello, How are you?" using ASCII/UTF-8
encoding.
Text in Binary System
Exercise
Answer:
• Vector Graphics
• Gray Code
Graphics in Binary System
Bit Mapped Graphics
Concept
❑ An image can be represented as a map of binary codes
❑ In a black and white image, only 1 Bit is needed to represent each pixel as the
pixel can only be black or white.
Graphics in Binary System
Bit Mapped Graphics
Example
In this example: Black and White Pixels Image 8x8 grid
❑ It is assumed that only black and white pixels in the image
❑ Black pixel represented by (1) in the BIT MAP of the image
❑ White pixel represented by (0) in the BIT MAP of the image
Pixel Pattern with 8x8 grid BIT MAP
Graphics in Binary System
Bit Mapped Graphics
Example
In this example: Black and White Pixels Image 10X10 Grid
Pixel Pattern using 8x8 Grid Pixel Pattern using 16x16 Grid
There is a one to one correspondence between pixels and bits
Graphics in Binary System
Bit Mapped Graphics
Colour Image
❑ The main difference between black-white and a colour image is the
number of Bits needed to represent each pixel
❑ Color Channels
o Red Channel (8 bits): Represents the intensity of red color.
o Green Channel (8 bits): Represents the intensity of green color.
o Blue Channel (8 bits): Represents the intensity of blue color.
RGB stands for Red, Green, and Blue
❑ BinaryValues
❑ Combining Channels
o For example:
• A binary value of 00000000 (0
in decimal) in the red channel
represents no red
❑ A more complex image is shown below and the grid and map of Bits is
clearly visible:
Graphics in Binary System
Bit Mapped Graphics
Resolution and Memory Storage
Assume that you have an image with 4 inches x 6 inches. The resolution is 300 d.p.i.
(dots per linear inch) and the image is black and white. Calculate the memory
requirements
𝟐 𝟏𝟔𝟎 𝟎𝟎𝟎
𝑺𝒕𝒐𝒓𝒂𝒈𝒆 = 𝟐 𝟏𝟔𝟎 𝟎𝟎𝟎 𝒃𝒊𝒕𝒔 = 𝒃𝒚𝒕𝒆𝒔 = 𝟐𝟕𝟎 𝟎𝟎𝟎 𝒃𝒚𝒕𝒆𝒔 = 𝟐𝟔𝟑. 𝟒 𝑲𝑩𝒚𝒕𝒆𝒔
𝟖
Audio in Binary System
Audio in Binary System
Representing Sound in Binary Systems
❑ Analogue sound is represented as a wave.
Audio in Binary System
Representing Sound in Binary Systems
To process sound in a computer and digital electronic devices, it must be
represented as binary codes. So, Sound is converted and stored in a binary
form.
Audio in Binary System
Representing Sound in Binary Systems
❑ To represent the varying values of a sound wave by a binary code, the
amplitude of wave must be Sampled
❑ Sampling Intervals
o Sampling is taken at regular time intervals, for example, one
sample is taken in every 30 milliseconds.
o This step reduces the continuous time domain into a series of
discrete intervals.
0
1 201
0
1 201
Impulse sampler
0
1 201
Signal(mt) Spectrum of
Unsampled
Signal M(f)
Freq
Sampling pulses
fs 2fs 3fs
Samples
fs 2fs 3fs
Time
Spectrum of Sampled Signal
Figure: General Sampling Method
Audio in Binary System
Sampling Process
Audio in Binary System
Sampling Rate
The sampling rate is chosen properly in relation to the bandwidth
of the message signal, so that the sequence of samples uniquely
defines the original analog signal.
Audio in Binary System
Sampling Rate
Audio in Binary System
Sampling Rate
Audio in Binary System
Sampling Rate
Audio in Binary System
Sampling Rate
Sampling Rate
Audio in Binary System
Representing Sound in Binary Systems
❑ Pulse Code Modulation (PCM)
o PCM is a widely used method for encoding analog audio into digital form.
o It samples the analog audio waveform at regular intervals and quantizes each
sample into a binary value.
o The bit depth (e.g., 8-bit, 16-bit, 24-bit) determines the range of values each
sample can have, which in turn affects the audio quality.
Thank You