Title: COMPUTER ORGANIZATION AND ARCHITECTURE
1COMPUTER ORGANIZATION ANDARCHITECTURE
- Chapter 2Number System and Data Representation
2Chapter II Number System and Data Representation
- 1. Number System
- 2. Data Representation
- 3. Integer Representation
31. Number Systems
- Fundamental to understand how computers work is
understanding the number system that computer use
to store data and communicate with each other. - Number system been used to understand computer
- Base 10 (decimal)
- E.g. 394510 / 3945d
- Base 2 (binary)
- E.g. 101010112 / 10101011b
- Base 16 (hexadecimal)
- E.g. 0A3E16 / 0A3Eh
4Number Systems (cont.)
- The Decimal System
- In everyday life we use a system based on decimal
digits. - Consider the number 4728 means four thousands,
seven hundreds, two tens, plus eight - 4728 (4 x 1000) (7 x 100) (2x10) 8
- The decimal system is said to have a base or
radix of 10. Each digit in the number is
multiplied by 10 raised to a power corresponding
to that digits position - 4728 (4 x 103) (7 x 102) (2 x 101) (8 x
100)
5Number Systems (cont.)
The Binary System
- In the binary system, we have only two digits, 1
and 0. Thus, number in the binary system are
represented to the base 2. - Each digits in a binary number also have a value
depending on its position - 1002 (1 x 22 ) (0 x 21 ) (0 x20 ) 410
- 101011b (1 x 25) (0 x 24) (1 x 23) (0 x
22) (1 x 21) - (1 x 20) 43d
6Number Systems (cont.)
The Hexadecimal System
- A computers world is a binary world and
communication of instruction and data by the
devices that process them is always in binary. - Binary system is very difficult for human being.
Human being are comfortable to decimal number
system. - However calculations to convert binary to decimal
are relatively complex. - A notation known as hexadecimal has been adopted.
Binary digits are grouped into sets of four. Each
possible combination of four binary digits is
given a symbol (hexadecimal digits) as follows
7Number Systems (cont.)
The Hexadecimal System (cont.)
0000 0 0001 1 0010 2 0011 3 0100 4 0101
5 0110 6 0111 7
1000 8 1001 9 1010 A 1011 B 1100 C 1101
D 1110 E 1111 F
8Number Systems (cont.)
The Hexadecimal System (cont.)
- In the hexadecimal system, we have 16 hexadecimal
digits. Thus, number in the hexadecimal system
are represented to the base 16. - Each digits in a hexadecimal number also have a
value depending on its position - 2C16 (2 x 161) (C x 160)
- (2 x 161) (12 x 160) 4410
- The reason for using hexadecimal notation are
because it is more compact than binary notation
and it is extremely easy to convert between
binary and hexadecimal.
9Number Systems (cont.)
10Conversion Between Number Systems
Number Systems (cont.)
- Converting Binary to Decimal
- Converting Hex to Decimal
- Converting Decimal to Binary
- Converting Decimal to Hex
- Converting Between Hex and Binary
11Converting Binary to Decimal
Number Systems (cont.)
- 101001b to decimal
- 101001b (1 x 25) (0 x 24) (1 x 23) (0 x
22) (0 x 21) (1 x 20) - 32 0 8 0 0 1
- 41d
12Number Systems (cont.)
Converting Hex to Decimal
- A3F16 to decimal
- A3F16 (A x 162) (3 x 161) (F x 160 )
- (10 x 256) (3 x 16) (15 x 1)
- 262310
13Converting Decimal to Binary
Number Systems (cont.)
- Decimal can be converted in to a binary systems
with the Remainder Method - Example Convert 26d to base 2
- gt 26d 11010b
26/2 13 0 13/2 6 1 6/2 3
0 3/2 1 1 1/2 0 1
14Number Systems (cont.)
Converting Decimal to Binary (Floating point
number)
- How about floating point number?
- E.g. Convert 0.875d into base 2 number.
-
- gt 0.875d 0.1110b
0.875 x 2 1.75 1 0.75 x 2 1.5 1 0.5
x 2 1.0 1 0 x 2 0 0
15Converting Decimal to Hex
Number Systems (cont.)
- Decimal can be converted into a hex with the
Remainder Method - Example Convert 425d to base 16
- 425 / 16 26 9 -gt 9
- 26 / 16 1 10 -gt A
- 1 / 16 0 1 -gt 1
- gt 425d 1A9h
16Converting Between Hex and Binary
Number Systems (cont.)
- To convert a hex number to binary, we need only
express each hex digit in binary - E.g. Convert DE116 to binary
- D E 1
- 1101 1110 0001
- 110111100001b
- To go from binary to hex, just reverse this
process - 100100012 1001 0001 9116
17 1. Number System 2. Data Representation 3.
Integer Representation
182. Data Representation
- A common form of data are letters of the alphabet
(A to Z), numerals (0 to 9), some symbols (_at_, ,
) and certain control character (Ctrl,Shift). - This types of data is convenient for human being
but all of the data in digital computer
represented in binary form. - Some coding systems are used to represent these
data into the binary form. (Characters are
represented by a sequence of bits.)
19Data Representation (cont.)
- The famous coding system been used for data
representation are - ASCII (American Standard Code for Information
Interchange) - EBCDIC (Extended Binary Coded Decimal Interchange
Code ) - BCD (Binary Coded Decimal)
20ASCII
Data Representation (cont.)
- ASCII is used in almost all present-day personal
computers. - Each alphabetic, numeric, or special character is
represented with a 7-bit binary number (a string
of seven 0s or 1s). - 128 possible characters can be represented.
- 27
- The eight bit may be set to 0 or used as a parity
bit for error checking on communication lines or
other device-specific functions. - Example char A65 in decimal,41 in hex,
0100Â 0001 in binary.
21Data Representation (cont.)
ASCII Control Characters
The first thirty-two codes (numbers 0-31 decimal)
in ASCII are reserved for control characters
codes that may not themselves represent
information, but that are used to control devices
(such as printers) that make use of ASCII. For
example, character 10 represents the "line feed"
function (which causes a printer to advance its
paper), and character 27 represents the "escape"
key found on the top left of common keyboards.
22Data Representation (cont.)
ASCII Printable Characters
Code 32 is the "space" character, denoting the
space between words, which is produced by the
large space bar of a keyboard.
Codes 33 to 126 are called the printable
characters, which represent letters, digits,
punctuation marks, and a few miscellaneous
symbols.
23Data Representation (cont.)
ASCII Printable Characters
24Data Representation (cont.)
ASCII Printable Characters (cont.)
25Data Representation (cont.)
ASCII Printable Characters (cont.)
26EBCDIC
Data Representation (cont.)
- EBCDIC (pronounced either "ehb-suh-dik" or
"ehb-kuh-dik") is a binary code for alphabetic
and numeric characters that IBM developed for its
larger operating systems - Each alphabetic or numeric character is
represented with an 8-bit binary number (a string
of eight 0's or 1's). - 256 possible characters (letters of the alphabet,
numerals, and special characters) are defined. - EBCDIC uses more or less the same characters as
ASCII, but different code points. Example A C1
in hex, 1100 0011 in binary. - Today outside IBM everyone uses ASCII instead
EBCDIC is considered a bit of a dinosaur.
27Data Representation (cont.)
BCD
- In BCD, 4 bit binary number were used to
represent 1 decimal number ( e.g 3d0011b,
9d1001b) - Highest decimal number were coded to BCD is 9
(1001). Thus, 1010, 1011, 1110 and 1111 were not
used. - To encode the number such as 43 use
- 43d 0100 0011b
- The BCD format usually used in the BIOS at
Personal Computer (PC) to keeps the date and time
for historical reason.
28 1. Number System 2. Data Representation 3.
Integer Representation
293. Integer Representation (cont.)
- For the purpose of computer storage and
processing, only binary digits (0 and 1) may be
used to represent numbers (negative or positive). - For a 8-bit number, there are 28 256 possible
bit patterns. - For unsigned number, we can represent 0 to 255
using 8-bit number. - For signed number, the most significant
(leftmost) bit usually used as a sign bit. ( 0
for positive and 1 for negative number).
30Integer Representation (cont.)
- There are several alternative conventions used to
represent negative integers. Some of them are
- Signed magnitude
- Ones complement
- Twos complement
31Signed Magnitude
Integer Representation (cont.)
- Also know as sign and magnitude, the leftmost
bit is the sign and the rest are magnitude - 0 positive
- 1 negative
- Sign Magnitude
32Integer Representation (cont.)
Signed Magnitude (cont.)
- Example (for 8-bit number)
- 25d 0 0011001b
- -25d 1 0011001b
- Largest number is 127 and smallest number is
127 - ProblemsTwo representations for zero
- 0 00000000b
- -0 10000000b
33Ones Complement
Integer Representation (cont.)
- The leftmost bits is the sign ( 0 positive, 1
negative) - Negative number is obtained by complementing each
bit from 0 to 1 or from 1 to 0 - Example (8-bit number)
- 25d 00011001b
- -25d 11100110b
- Two representation of zero 0d 00000000b and
-0d 11111111 - Largest number is 127 and smallest number is -127
34Integer Representation (cont.)
Twos complement
- The leftmost bit is the sign bit (0positive, 1
negative) - Negative of the number is obtained by adding 1 to
the ones complement negative, - Example(8-bit number)
- 25d 00011001b
- -25d 11100111b
- One representation for zero 0000000b
- Largest number is 127 and smallest number is -128
35Range in Integer Representation
Integer Representation (cont.)
- For n bit number, highest integer value can be
represent is 2n-1 -1.
36- Number System
- Data Representation
- Integer Representation