Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Unit 1.1 Data Formats

Uploaded by

Mario
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Unit 1.1 Data Formats

Uploaded by

Mario
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Introduction to Data

Communication Systems and


Networks

Data Formats
By
KAORA/ KUNDA/CHILUMBU
Objectives
Understand how data is
represented, and stored, inside
a computer.
Understand how data is
manipulated inside a computer.

Understand how we represent that


data externally for easier
understanding and manipulation
by humans
Perform data conversions.
Topic & Structure of the lesson

◼ General Considerations
◼ Number systems and Inter-conversion
◼ Internal Computer Data format
Key Terms you must be able to use

◼ If you have mastered this topic, you should be able to


use the following terms correctly in your assignments
and exams:-
◼ Decimal
◼ Binary
◼ Octal
◼ Hexadecimal
Data Formats

◼ Computers
◼ Process and store all forms of data in binary format.

◼ Data formats
◼ Specifications for converting data into computer-usable
form.
◼ Define the different ways human data may be
represented, stored and processed by a computer.
Digital vs. Analog

◼ Computing systems are finite machines. They store a


limited amount of information, even if the limit is very big.

◼ The goal is to represent enough of the real world data


to satisfy our computational needs and our senses of
sight and sound.
◼ The information can be represented in one or two
ways: analog or digital.
Digital vs. Analog

◼ Analog data is a continuous representation, analogous to


the actual information it represents.

◼ For example, a mercury thermometer is an analog


device. The mercury rises in a continuous flow in the
tube in direct proportion to the temperature.
Digital vs. Analog

◼ Digital data is a discrete representation, breaking the


information up into separate (discrete) elements.

◼ Computers cannot work with analog information


directly, so there is a need to digitise the analog
information.
◼ This is done by breaking the analog information into
pieces and representing those pieces using binary
digits.
Digital vs. Analog

◼ Why digital signal?


◼ Both electronic signals (analog and digital) degrade
as they move down a line. The voltage of the signal
fluctuates due to environmental effects.
◼ As soon as an analog signal degrades, information
is lost. Since any voltage level within the range is
valid, it is impossible to know that the original signal
was even changed.
◼ Digital signals jump sharply between two extremes
(high and low state). A digital signal can degrade
quite a bit before the information is lost, because
any value over a certain threshold is considered
high value and below the threshold is considered
low value.
Digital vs. Analog (10 combines class software
Engineering and cyber Security)

◼ You can still retrieve the information from a reasonably


degraded digital signal.
◼ Periodically a digital signal is re-clocked to regain its
original shape. As long as it is re-clocked before too much
degradation, no information is lost.

1 1 Threshold
1 1 1 1 1 1
0 0 0 0 0 0 0 0
Digital Signal
Digital Signal Degradation

Analog Signal Analog Signal Degradation


Binary Representation

◼ Why binary representation (as opposed to decimal or


octal, etc..)?
◼ Because the devices that store and manage the digital
data are far less expensive and complex for binary
representation.
◼ They are also far more reliable when they have to
represent one out of two possible values.
◼ Because the electronic signals are easier to maintain if
they carry only binary data.
Binary Representation

◼ One bit can be either 0 or 1. Therefore, one bit can represent


only two outputs.
◼ To represent more than two outputs, we need multiple bits.
Two bits can represent four outputs because there are four
combinations of 0 and 1 that can be made from two bits: 00,
01, 10,11.
◼ In general, n bits can represent 2n outputs because there are
2n combinations of 0 and 1 that can be made from n bits.
Note that every time we increase the number of bits by 1, we
double the number of things we can represent.
Number System
Binary, Decimal, Conversion
Problems
A number system is a sequence
of symbols used to express
quantities or sets of items. It is
also called numerals.
Number System
Binary, Decimal, Conversion
Problems
• Various symbols are used to express
different quantities.
• If ten symbols are used to express various
quantities, then the number system is
based on ten symbols or simply called base
10. Also called radix of 10
• If two symbols are deemed sufficient to
express any quantity, then the numbers
system based on the two symbols is called
base 2. Also called radix of 2 .ETC, ETC
Number System
Binary, Decimal, Conversion
Problems
• The following numbers
systems are commonly used
in computing:
• Base 2 - Binary
• Base 8 - Octaldecimal
• Base 10 - Decimal
• Base 16 - Hexadecimal
Decimal Number System
• Ten separate symbols are used
(0,1,2,3,4,5,6,7,8,9)
• Each digit in a given number contributes to
the total worth of the number by adding its
place value.
• The place value is the product of the digit
with exponent of the place (or position).
• The total worth of the number is the
addition of the all the place values.
Decimal Number System
• Example
• Consider the number 3672.31
• Total worth = 3x10 + 6 x10 + 7 x10 + 2 x10 + 3x10 + 1x10
3 2 1 0 −1 −2

= 3000 + 600+70+0.3+0.01
= 3672.31
We the proceed with performing all sorts of
mathematical operations on these numbers.
Binary Number System
• This numbers system uses radix of 2 so
that there are only two symbols (1 and 0
called bits) used to represent all
numbers. Example is a number such as
101.11
• The place values of each bit is
−1 −2
1x 2 + 0 x 2 + 1x 2 + 1x 2 + 1x 2
2 1 0
Binary Number System

• Total worth =1x 2 2 + 0 x 21 + 1x 2 0 + 1x 2 −1 + 1x 2 −2


= 4+0+1+0.5+0.25
= 5.75
Note that this process actually converts the
number to base 10.
Binary To Decimal Conversion
Convert the following binary numbers into
decimal numbers
1011.1012
1101.0112
Decimal to binary Conversion
Convert the following decimal numbers into
binary numbers

11.62510

13.37510
Such problems are solved by repeated division
and repeated multiplication by 2
Decimal to binary Conversion
We treat the whole number part and decimal part
separately 1110 0.625 10

2 11 C
0.625 x 2 = 0.25 1
2 51 0.25 x 2 = 0.5 0
2 21 10112 0.5 x 2 = 0 1
2 1 0 101
01 11.62510 = 1011.1012
Decimal to binary Conversion
Class activity

Convert 13.375 to base 2 (Answer is 1101.0112)

1310 0.37510

Convert the numbers 1 to 10 from decimal to binary


BINARY ADDITION
The rules of binary addition are as follows
02 + 02 = 02
0 2 + 12 = 12
12 + 0 2 = 12
12 + 12 = 10 2
BINARY ADDITION
Example. Add
110011
+ 101101
1100000

Add 11010.10 to 11.1 in base 2


BINARY SUBTRACTION
The rules of binary subtraction are:
• 0-0 = 0
• 1-0 = 1
• 1-1 = 0
• 0-1 = 1 with a borrow of 1
BINARY SUBTRACTION
Example. Subtract 0111 from 1001 in base 2
1001
- 0111
0010
BINARY SUBTRACTION
Example. Subtract 01011 from 10110 in base 2
10110
- 01011
1011
BINARY MULTIPLICATION
The rules of binary multiplication are as follows
• 0x0 = 0
• 0x1 = 0
• 1x0 = 0
• 1x1 = 1
BINARY MULTIPLICATION
Example. Multiply 111 by 101 in base 2
111
X 101
111
000
+ 111__
100011
BINARY MULTIPLICATION
1. Multiply 1101 by 1100 in base 2
and show that the answer is 10011100
2.Multiply 110.11 by 10.1 in base 2

3. Multiply 0.111 by 11 in base 2


BINARY DIVISION
The rules of binary division are as follows:
• 0÷1=0
• 1÷1=1
• 0 ÷ 0 = indeterminate
• 1 ÷ 0 = indeterminate
BINARY DIVISION
Example. Divide 11001 ÷ 100 in base 2
110.01
100 11001
-100
100
-100
0100
-100
BINARY DIVISION
Example. Divide 11001 ÷ 101 in base
101
101 11001
-101
101
-101
0
BINARY DIVISION
Show that 11011 ÷ 100 in base 2 is 110.11
Octaldecimal numbers system
Octal numbers have a radix of eight. The counting
uses 0,1,2,3,4,5,6,7 digits. The counting sequence
beyond 7 is as follows:
0 1 2 3 4 5 6 7
10 11 12 13 14 15 16 17
20 21 22 23 24 25 26 27
30 31 32 33 34 35 36 37
40 41 42 43 44 45 46 47
OCTAL TO DECIMAL
CONVERSION
This done by summation of powers of 8
Example: Convert 127.24 from base 8 to base 10

−1 −2
127.24 = 1x8 + 2 x8 + 7 x8 + 2 x8 + 4 x8
2 1 0

= 87.3125 in base 10
DECIMAL TO OCTAL
CONVERSION
This done by repeated division by 8 for whole
numbers and repeated multiplication by 8 for
decimal numbers

Example: Convert 175.15 from base 10 to base 8


DECIMAL TO OCTAL CONVERSION
We treat the whole number part and decimal part
separately
17510 0.1510
8 175 C
0.15 x8 = 1.20 1
8 21 7
8 25 2578 0.2 x8 = 1.6 1
0.6 x8 = 4.8 4
0 2 1148
175.1510 = 257.1148
DECIMAL TO OCTAL
CONVERSION
Attempt

1. Convert 756.3 from base 10 to base 8


2. Convert 850.46 from base 10 to base 8
BINARY TO OCTAL CONVERSION
It is possible to convert binary numbers to
octaldecimal numbers by arranging the binary digits
into triplets
Example: Convert 101011 from base 2 to base 8
101 011

5 3
1010112 = 538
BINARY TO OCTAL CONVERSION
Show that 1111101112 = 7678
10101.112 = 25.68
OCTAL TO BINARY TO CONVERSION
In this case each digit in the given octal number is
converted to its binary triplet as follows

Convert 74.5628 to base 2


7 4 . 5 6 2

111 100 . 101 110 010


74.5628 = 111100.1011100102
Hexadecimal numbers system
Hexa numbers have a radix of 16. This is base 16.
The counting uses 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
digits. The counting sequence beyond 7 is as
follows:
0 1 2 3 4 5 6 7 8 9 A B C D E F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F etc
etc
BINARY TO HEXA CONVERSION
It is possible to convert binary numbers to
hexadecimal numbers by arranging the binary digits
into 4 bit sub groups
Example: Convert 10001100 from base 2 to base 16
1000 1100

8 12 but 12 is C in hexadecimal
10001100 2 = 8C16
BINARY TO HEXA CONVERSION
Example: Convert 1011010111 from base 2 to base
16
0010 1101 0111

2 13 7
but 13 is D in hexadecimal
10110101112 = 2 D716
HEXA TO DECIMAL CONVERSION
This done by summation of powers of 16
Example: Convert F6D9 from base 16 to base 10

F6C9 = Fx16 + 6 x16 + Cx16 + 9 x16


3 2 1 0

= 15 x16 + 6 x16 + 13 x16 + 9 x16


3 2 1 0

= 6319310
DECIMAL TO HEXA CONVERSION
This done by repeated division by 16 for whole
numbers and repeated multiplication by 16 for
decimal numbers. Convert 1983 to base 16
10

16 1983
16 123 15( F )
16 7 11( B)
0 7
198310 = 7 BF16
Binary Conversion (BIT class)

◼ Decimal to Binary
◼ 2510 = 1 10012
◼ 14510 = 1001 00012
◼ 210 = 102

◼ Binary to Decimal
◼ 1111 00002 = 24010
◼ 11112 = 1510
◼ 1002 = 410
Binary Conversion

◼ Octal to Binary
◼ 258 = 010 1012
◼ 1458 = 001 100 1012
◼ 28 = 0102

◼ Binary to Octal
◼ 1111 00002 = 3608
◼ 11112 = 178
◼ 1002 = 48
Binary Conversion

◼ Hexadecimal to Binary
◼ 2516 = 0010 01012
◼ 14516 = 0001 0100 01012
◼ 216 = 00102
◼ Binary to Hexadecimal
◼ 1111 00002 = F016
◼ 11112 = F16
◼ 1002 = 416
Addition and Subtraction of Binary Numbers – Signed
Magnitude (BICT with Education Class afternoon
today)

❑ Representing negative numbers


-6 and -7

16 8 4 2 1
0 0 1 1 0

Magnitude
Sign
-6 1 1 1 0
Flip 0 to 1

Practice with -7 and add 7 to verify the answer.


Addition and Subtraction of Binary Numbers

◼ Signed numbers
8 4 2 1
0 1 1 1 = +7
+ 1 1 1 1 = -7

1 1 1 1 0 =0

14

The calculation after conversion gives a wrong number, hence the use of the 2’s Complement
Binary Conversion

◼ 2’s Complement
+2510 = 1 10012
-2510 = ?
1 10012 (+25)
0 01102 (flip the bits)
+ 1 (add 1)
0 0111
-2510 = 111001112
Examples
-12 and -15
Binary Conversion – Fractional Numbers to Decimal

◼1011.1010
1 * 2-1 = 0.500
1 * 2-3 = 0.125
1 * 20 = 1
1 * 21 = 2
1 * 23 = 8
11.62510 Answer
Binary Coded Decimal

◼ The binary-coded-decimal (BCD) system is used to


represent each of the 10 decimal digits as a 4-bit
binary code.
◼ This code is useful for outputting to displays that are
always numeric (0 to 9), such as those found in
digital clocks or digital voltmeters.
◼ To form a BCD number, simply convert each decimal
digit to its 4-bit binary code.
Binary Coded Decimal

◼ Convert 4 9 610 to BCD.


◼ Solution:
4 = 0100
9 = 1001
6 = 0110 = 0100 1001 0110BCD Answer

Practice
Convert 0111 0101 1000BCD to decimal.
Binary Conversion

Binary Decimal Octal Hexadecimal


0000 0000 0 0 0
0000 0001 1 1 1
0000 0010 2 2 2
0000 0011 3 3 3
0000 0100 4 4 4
0000 0101 5 5 5
0000 0110 6 6 6
0000 0111 7 7 7
Binary Conversion

Binary Decimal Octal Hexadecimal


0000 1000 8 - 8
0000 1001 9 - 9
0000 1010 10 - A
0000 1011 11 - B
0000 1100 12 - C
0000 1101 13 - D
0000 1110 14 - E
0000 1111 15 - F
Data Representation - ASCII

• Stands for American Standard Code for Information


Interchange
• Computers can only understand numbers, so an ASCII
code is the numerical representation of a character
such as 'a' or '@' or an action of some sort.
• ASCII codes represent text in computers,
communications equipment, and other devices that
work with text
• Originally consisted of 7 bits for each character, later it
has been extended to 8 bits (127 characters)
Data Representation

How is a letter converted to binary form and back ?


Step 1.
The user presses Step 2.
the capital letter D An electronic signal for the
(shift+D key) on capital letter D is sent to the
the keyboard. system unit.

Step 4. Step 3.
After processing, the binary code for the
The signal for the capital letter D is converted
capital letter D is converted to an image, to its ASCII binary code (01000100) and is
and displayed on the output device. stored in memory for processing.
Summary of Main Teaching Points

◼ Data must be converted from its native format


into form understood by processing device in
order to be processed by the CPU.
◼ All data represented within a modern computer
system as strings of binary digits, or bits.
◼ Each bit string has a specific data format &
coding method.
◼ Characters converted to numbers via coding
table.
Next Session

◼ OSI Model
Question and Answer Session

Keep Working Hard!

Q&A

You might also like