You are on page 1of 17

Saba university

Faculty of Computer Science

Computer Fundamentals

Data Representation

Khalil Ahmad Faizi

1
What is in this course?

Basics of Computer
–Computer system hardware
–Computer memory
–Input and Output devices
–Data representation

User-Computer Interface
–Interaction of user and computer
–Operating Systems
–Computer Programming Fundamentals
–Data communication and computer networks
2
–The Internet and Internet Services
Introduction

Computers store & process data

Data is anything that has some interest to the user

Thoughtfully processed data is called information
Physical devices used to store & process data in computers are 2-

state devices

State is represented using;
–0 – OFF
–1 - ON

3
Introduction

4
Introduction (Bit & Byte)

An abbreviation for Binary digit

Bit is the smallest unit of data representation

When 8 bits are combined together it is called a
byte

Byte represent one character

5
Introduction (Bit & Byte)

Computers represent numbers as a series of switches which store a
pattern of ON's & OFF's, representing the binary digits 1 & 0.

Each of these digits is called a BIT (Binary digiT)
● 7 6 5 4 3 2 1 0

1 1 0 1 1 0 0 1

MSB – Most significant bit LSB – Least significant bit

6
Coding Systems
–Binary Coded Decimal System (BCD): IBM PC used this, 6-bit
character codes (0 - 64)
–Standard ASCII: 7-bit character codes (0 – 127)

–Extended ASCII: 8-bit character codes (0 – 255)


–Unicode: 16-bit character codes (0 – 65,535)
–Unicode standard represents a universal character set

Defines codes for characters used in all major
languages

Used in Windows-XP: each character is encoded as
16 bits
Printable ASCII Codes
0 1 2 3 4 5 6 7 8 9 A B C D E F
2 spac
e
! " # $ % & ' ( ) * + , - . /
3 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4 @ A B C D E F G H I J K L M N O
5 P Q R S T U V W X Y Z [ \ ] ^ _

6 ` a b c d e f g h i j k l m n o
7 p q r s t u v w x y z { | } ~ DE
L

 Examples:
 ASCII code for space character = 20 (hex) = 32 (decimal)
 ASCII code for 'L' = 4C (hex) = 76 (decimal)
 ASCII code for 'a' = 61 (hex) = 97 (decimal)
Number Systems
Common Number Systems are Decimal, Binary, Octal

and Hexadecimal.

Table 6.1-Number Bases

9
Number systems

Decimal Number: has ten digits: (0, 1, 2, 3, 4, 5, 6, 7, 8,
9)


Binary numbers: has two digits: 0 and 1

A digit in Base 16 can range from 0 to 16-1
(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). Use letters A-F to
represent values 10 to 15. Base 16 is also called
Hexadecimal or just ‘Hex’.

A digit in base R can range from 0 to R-1
10
Decimal Number System

The number 4567 in base 10 means:

4567 = four thousand five hundred and sixty seven

= 4000 + 500 + 60 + 7
= (4 × 1000) + (5 × 100) + (6 × 10) + (7 × 1)
= (4 × 10 3 ) +(5 × 10 2 ) +(6 × 10 1 )+(7 ×10
0)

11
Binary Numbers

Each binary digit (called bit) is either 1 or 0


Bit Numbering
–Least significant bit (LSB) is rightmost (bit 0)
–Most significant bit (MSB) is leftmost (bit 7 in an 8-bit number)

Most Least
Significant Bit Significant Bit
7 6 5 4 3 2 1 0

1 0 0 1 1 1 0 1

7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2
Comparison of binary, decimal, octal and
hexadecimal numbers

13
Examples:
1011.11 = 1x23 + 0x22 + 1x21 + 1x20 + 1x2-1 + 1x2-2 2-3 = 0.125
= 8 + 0 + 2 + 1 + 0.5 + 0.25 2-2 = 0.25
= Binary 2-1 = 0.5
11.75 20 = 1
21 = 2
953.78 = 9 x 102 + 5 x 101 + 3 x 100 + 7 x 10-1 + 8 x 10-2 22 = 4
= 900 + 50 + 3 + .7 + .08 = 953.78
23 = 8
Decimal
24 = 16
25 =32
A2F = 10x162 + 2x161 + 15x160 26 = 64
= 10 x 256 + 2 x 16 + 15 x 1
= 2560 + 32 + 15 = 2607 Hexadecimal
27 = 128
28 = 256
160 = 1 = 20 29 = 512
161 = 16 = 24 210 = 1024
162 = 256 = 28 211 = 2048
163 = 4096 = 212 212 = 4096
14
Conversions: Hex to Binary, Binary to Hex

Hex to Binary

A2 = 1010 0010 1111
F
= 0011 0100

345 0101

Binary to Hex

Binary to Hex is just the opposite, create groups of
4 bits starting with least significant bits. If last
group does not have 4 bits, then pad with zeros for
unsigned numbers.

1010001 = 0101 0001 = 51


15
Padded with zero
Conversion of Decimal Integer To ANY Base

Divide Number N by base R until quotient is 0.
Remainder at EACH step is a digit in base R, from Least
Significant digit to Most significant digit.


Convert 53 to binary
53/2 = 26, rem = 1 Least Significant Digit
26/2 = 13, rem = 0
13/2 = 6 , rem = 1
6 /2 = 3, rem = 0
3/2 = 1, rem = 1 Most Significant Digit
1/2 = 0, rem = 1

53 = % 110101
= 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20
= 32 + 16 + 0 + 4 + 0 + 1 = 53 16
Thank you from your attention!

17

You might also like