Lecture 2 3 Number System
Lecture 2 3 Number System
ASSEMBLY LANGUAGE
Data Representation
NUMBER SYSTEM
2
POSITIONAL NUMBER SYSTEM
A computer can understand positional number system where there are only a few
symbols called digits and these symbols represent different values depending on
the position they occupy in the number.
A value of each digit in a number can be determined using
The digit
The position of the digit in the number
The base of the number system (where base is defined as the total number of
digits available in the number system).
3
DECIMAL NUMBER SYSTEM
4
BINARY NUMBER SYSTEM
5
HEXADECIMAL NUMBER SYSTEM
6
CONVERSION BETWEEN NUMBER SYSTEMS
7
CONVERSION BETWEEN NUMBER SYSTEMS
8
CONVERSION BETWEEN NUMBER SYSTEMS
9
CONVERSION BETWEEN NUMBER SYSTEMS
10
CONVERSION BETWEEN NUMBER SYSTEMS
11
Binary, Decimal, and Hexadecimal Equivalents.
0000 0 0 1000 8 8
0001 1 1 1001 9 9
0010 2 2 1010 10 A
0011 3 3 1011 11 B
0100 4 4 1100 12 C
0101 5 5 1101 13 D
0110 6 6 1110 14 E
0111 7 7 1111 15 F
BINARY ARITHMETIC OPERATIONS
Addition
Like decimal numbers, two numbers can be added by adding each pair
of digits together with carry propagation.
11001 647
+ 10011 + 537
101100 1184
13
BINARY ARITHMETIC OPERATIONS
Subtraction
Two numbers can be subtracted by subtracting each pair of digits
together with borrowing, where needed.
11001 627
- 10011 - 537
00110 090
14
HEXADECIMAL ARITHMETIC OPERATIONS
Addition
Like decimal numbers, two numbers can be added by adding
each pair of digits together with carry propagation.
5B39
+ 7AF4
D62D
Hexadecimal Addition
15
16
HEXADECIMAL ARITHMETIC OPERATIONS
Subtraction
Two numbers can be subtracted by subtracting each pair of digits
together with borrowing, where needed.
D26F
- BA94
17DB
Hexadecimal Subtraction
17
MSB AND LSB
In computing, the most significant bit (msb) is the bit position in a binary
number having the greatest value. The msb is sometimes referred to as the
left-most bit.
In computing, the least significant bit (lsb) is the bit position in a binary
integer giving the units value, that is, determining whether the number is
even or odd. The lsb is sometimes referred to as the right-most bit.
18
UNSIGNED INTEGERS
19
SIGNED INTEGERS
Example:
00001010 = decimal 10
10001010 = decimal -10
20
ONE’S COMPLEMENT
21
2’S COMPLEMENT
Example
11110011 (one's complement of 12)
+ 00000001 (decimal 1)
11110100 (two's complement of 12)
22
DECIMAL INTERPRETATION
23
EXAMPLE
25
CHARACTER REPRESENTATION
26
27
HOW TO CONVERT?
28
CHARACTER STORAGE
123
123 = 01111011
29
FLOATING POINT REPRESENTATION
30
FLOATING POINT
-15900000000000000
could be represented as
Mantissa Base
34