Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Number Systems

Similar presentations


Presentation on theme: "Introduction to Number Systems"— Presentation transcript:

1 Introduction to Number Systems

2 Storyline … Different number systems Why use different ones?
Binary / Octal / Hexadecimal Conversions Negative number representation Binary arithmetic Overflow / Underflow

3 Number Systems Four number system Decimal (10) Binary (2) Octal (8)
Hexadecimal (16)

4 Binary numbers? Computers work only on two states
Off Basic memory elements hold only two states Zero / One Thus a number system with two elements {0,1} A binary digit – bit !

5 Decimal numbers 1439 = 1 x 103 + 4 x 102 + 3 x 101 + 9 x 100
Thousands Hundreds Tens Ones Radix = 10

6 Binary Decimal 1101 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20
= (1101)2 = (13)10 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ….

7 Decimal Binary 2 13 LSB 1 2 6 2 3 1 2 1 1 MSB (13)10 = (1101)2

8 Octal Decimal 137 = 1 x 82 + 3 x 81 + 7 x 80 = 1 x 64 + 3 x 8 + 7 x 1
= (137)8 = (95)10 Digits used in Octal number system – 0 to 7

9 Decimal Octal 8 95 LSP 7 8 11 3 8 1 1 MSP (95)10 = (137)8

10 Hex Decimal BAD = 11 x x x 160 = 11 x x x 1 = (BAD)16 = (2989)10 A = 10, B = 11, C = 12, D = 13, E = 14, F = 15

11 Decimal Hex 16 2989 LSP 13 16 186 10 16 11 11 MSP (2989)10 = (BAD)16

12 Why octal or hex? Ease of use and conversion
Three bits make one octal digit => in octal Four bits make one hexadecimal digit E B => EB5 in hex 4 bits = nibble

13

14 Negative numbers Three representations Signed magnitude 1’s complement

15 Sign magnitude Make MSB represent sign Positive = 0 Negative = 1
E.g. for a 3 bit set “-2” Sign Bit 1 MSB LSB

16 1’s complement MSB as in sign magnitude Complement all the other bits
Given a positive number complement all bits to get negative equivalent E.g. for a 3 bit set “-2” Sign Bit 1

17 2’s complement 1’s complement plus one E.g. for a 3 bit set “-2” Sign

18 Decimal number 3 011 2 010 1 001 000 -0 100 --- 111 -1 101 110 -2 -3
Signed magnitude 2’s complement 1’s complement 3 011 2 010 1 001 000 -0 100 --- 111 -1 101 110 -2 -3 -4 No matter which scheme is used we get an even set of numbers but we need one less (odd: as we have a unique zero)

19 Binary Arithmetic Addition / subtraction Unsigned Signed
Using negative numbers

20 Unsigned: Addition Like normal decimal addition B A 0101 (5)
The carry out of the MSB is neglected + 1 10 0101 (5) (9) 1110 (14)

21 Unsigned: Subtraction
Like normal decimal subtraction B A A borrow (shown in red) from the MSB implies a negative - 1 11 1001 (9) (5) 0100 (4)

22 Signed arithmetic Use a negative number representation scheme
Reduces subtraction to addition

23 2’s complement Negative numbers in 2’s complement 001 ( 1)10
001 ( 1)10 101 (-3)10 110 (-2)10 The carry out of the MSB is lost

24 Overflow / Underflow Maximum value N bits can hold : 2n –1
When addition result is bigger than the biggest number of bits can hold. Overflow When addition result is smaller than the smallest number the bits can hold. Underflow Addition of a positive and a negative number cannot give an overflow or underflow.

25 Overflow example 011 (+3)10 110 (+6)10 ????
110 (+6) ???? 1’s complement computer interprets it as –1 !! (+6)10 = (0110)2 requires four bits !

26 Underflow examples Two’s complement addition 101 (-3)10
Carry (-6) ???? The computer sees it as +2. (-6)10 = (1010)2 again requires four bits !


Download ppt "Introduction to Number Systems"

Similar presentations


Ads by Google