Chapter Four

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 20

Chapter Four

Data Representation in Computer


Introduction to computer application

02/22/22 Compiled by Hana M. 1


Objectives:

To understand different number systems


To understand conversion between different number
systems
To understand how to apply arithmetic operations on
binary number systems
To know how to represent signed and unsigned numbers
To know different data coding systems and unit of data
representation
To understand how really data represented, flow, stored
and processed inside the computer

02/22/22 Compiled by Hana M. 2


Data Representation
Data represented in a computer in the form of code which
can have a corresponding electrical signal
Data is represented in a way as series of electrical switches
in arranged manner
Data stored, processed or communicated within a
computer system in different units like bit, byte and word
Bit:
 the smallest unit of data representation
 A single element in a computers which has only two possible

states, 0 and 1 (indicates OFF and ON respectively)


 Stands for Binary Digit

02/22/22
Compiled by Hana M. 3
Cont.
Byte:
 the basic unit of data representation
 Commonly contains 8 bits (can represent 256 characters)

 Represent a character

 Used as a unit of measurement in a computer memory, processing unit, external

storage and communication


 Stands for Binary Digit

Word:
 The number of bits that a computer processes at a time or a transmission media
transmits at a time
 Is a combination of bytes (1, 2, 3 or 4 based on the capacity of the computer)

 Word length is usually expressed in bits

 The large the word length a computer has the more powerful and faster it is.

 Bytes can store/transmit information but, slow in speed

 Example: 8, 16, 32 and 64 bit operating system computers

02/22/22 Compiled by Hana M. 4


Cont.
Data Encoding Techniques
A method of representing characters in any language in a
computer system
The most common data encoding techniques are: ASCII-7,
ASCII, BCD, EBCDIC and UNICODE.
ASCII-7:
 American Standard Code for Information Interchange
 Uses 7 bits to re[present a character

 128 different characters can be coded by using this technique


(0000000 - 1111111)
 It has Zone and Digit Positions

 Used widely before the introduction of ASCII-8

02/22/22 Compiled by Hana M. 5


Cont.
 Example:

ASCII:
 Referred as ASCII-8 or Extended ASCII
 Most widely used type of coding scheme for micro computers

 Uses 8 bits to represent a character

 Can represent 256 different symbols (00000000 - 11111111)

 No Zone and Digit positions in ASCII

02/22/22 Compiled by Hana M. 6


Cont.
Example:

BCD:
 Binary Coded Decimal
 Also called packet decimal

 Uses 6 bits to code characters

 Has Zone and Digit Positions


 Encode decimal numbers in which each digit is represented by its own binary sequence

 used in most early IBM computers

02/22/22 Compiled by Hana M. 7


Cont.
 Example:

EBCDIC:
 Extended Binary Coded Decimal Interchange Code
 Uses 8 bits to represent a character (00000000 - 11111111)
 Accommodates to code 256 different characters
 Standard coding schema for large computers
 Has Zone and Digit
02/22/22 Compiled by Hana M. 8
Cont.
 Example:

UNICODE:
 provide a single character set that covers the language of the world & a small number of machine
friendly forms and schemes
 Designed for best interoperability with ASCII & ISO-8859-1

 Covers all the characters of the world

 Preferred character set for internet (HTML and XML)

02/22/22 Compiled by Hana M. 9


Cont.

02/22/22 Compiled by Hana M. 10


Number System

• A writing system for expressing numbers


• A set of symbols used for counting
• Example:
– Decimal Number systems

– Binary Number systems

– Octal Number systems

– Hexadecimal Number Systems

• The value of each digit in a number can be determined using:


− The digit (Roman Number Systems)
− The position of the digit in the number (weight a base associated with it)
− The base of the number system
• Base is the total number of the digits available in the number
system
02/22/22 Compiled by Hana M. 11
Cont.
 Decimal Number System
 Common and widely used number system
 Is based on ten different digits (Symbols)
 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9
 Inconvenient for representing data in computer
 Each position represents a power of the base (10)
 Binary Number Systems
 Based on two different digits
 0 and 1
 Has similar nature with electronic devices (two elementary states)
 Convenient to represent data in computers
 Each position represents a power of the base (2)

02/22/22 Compiled by Hana M. 12


Cont.
 Octal Number System
 Is based on eight different digits (Symbols)
 0, 1, 2, 3, 4, 5, 6, and 7
 Same with decimals from 0 to 7
 Sometimes convenient since many computer operations are based on bytes
 Each position represents a power of the base (8)
 Hexadecimal Number Systems
 Based on sixteen different digits
 0, 1, 2, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F
 Same with decimals from 0 to 9
 Convenient to represent groups of 4 bits
 Used for computation and memory adresses
 Each position represents a power of the base (16)

02/22/22 Compiled by Hana M. 13


Coding Method

 Conversion from Decimal to other base B


 Divide the number in decimal by the base B

 Find/record the remainder

 Divide the result by the base B

 Find/record the reminder

 Repeat it until the result is 0

 Concatenate the reminders starting from the last up to the first

 Conversion from base B to Decimal


– Determine the positional value of each digit

– Multiply the obtained positional value by the corresponding digit


– Sum the products

02/22/22 Compiled by Hana M. 14


Cont.
 Conversion from Binary to Octal
– Divide the binary digits into groups of 3 (start from the right)

– Convert each group of three binary digits to one octal digit

 Conversion from Binary to Hexadecimal


– Divide the binary digits into groups of 4(start from the right)
– Convert each group of four binary digits to one hexadecimal digit/symbol
 Conversion from Octal to Binary
– Convert each octal digit into a 3 digit binary number
– Combine all the resulting binary groups into a single binary number

 Conversion from Hexadecimal to Binary


– Convert each hexadecimal digit into a 4 digit binary number
– Combine all the resulting binary groups into a single binary number
 Conversion from hexadecimal to octal
- converting to binary and then to octal
 Conversion from octal to hexadecimal
-converting to binary
02/22/22 and
Compiled then
by Hana M. to hexadecimal 15
Cont.
Conversion from Octal to Decimal
Conversion from Decimal to Octal
Conversion from Decimal to Hexadecimal
Conversion from Hexadecimal to Decimal

02/22/22 Compiled by Hana M. 16


Cont.

02/22/22 Compiled by Hana M. 17


Cont.
Binary Arithmetic (Binary Computation)
Binary Addition:
 Operates by the same rule as decimal addition
 It is simple

 Carry to the next higher order position when the sum is decimal 2, that is binary
10.
 Rules:
 0+0 = 0

 0+1 = 1

 1+0 = 1

 1+1 = 0 carry 1 to the next position

 1+1+1 = 1 carry 1 to the next position

 Example:
 110 + 111 = 1101 and 100101 + 11111 = 1000100

02/22/22 Compiled by Hana M. 18


Cont.

02/22/22

02/22/22 Compiled by Hana M. 19


Cont.
Binary Division:
 Similar to decimal division
 The process of dividing one binary number by another
 Based on the rules for binary subtraction & multiplication
 Example: 1111101 ÷ 11001 = ?
 1111101 | 11001

11001 101
11001
11001
00000

02/22/22 Compiled by Hana M. 20

You might also like