Presentation is loading. Please wait.

Presentation is loading. Please wait.

Number Systems.

Similar presentations


Presentation on theme: "Number Systems."— Presentation transcript:

1 Number Systems

2 Number Representation
Every number like ‘a’ can be represented as

3 Common Number Systems System Base Symbols Used by humans?
Used in computers? Decimal 10 0, 1, … 9 Yes No Binary 2 0, 1 Octal 8 0, 1, … 7 Hexa- decimal 16 0, 1, … 9, A, B, … F

4 Quantities/Counting Decimal Binary Octal Hexa- decimal 1 2 10 3 11 4
1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000 9 1001 Decimal Binary Octal Hexa- decimal 10 1010 12 A 11 1011 13 B 1100 14 C 1101 15 D 1110 16 E 1111 17 F 10000 20 10001 21 18 10010 22 19 10011 23

5 Conversion Among Bases
The possibilities: Decimal Octal Binary Hexadecimal

6 The others to Decimal

7 Decimal to Decimal (just for fun)
Octal Binary Hexadecimal Next slide…

8 Weight 12510 => 5 x 100 = x 101 = x 102 = Base

9 Binary to Decimal Decimal Octal Binary Hexadecimal

10 Binary to Decimal Technique
Multiply each bit by 2n, where n is the “weight” of the bit The weight is the position of the bit, starting from 0 on the right Add the results

11 Example Bit “0” => 1 x 20 = x 21 = x 22 = x 23 = x 24 = x 25 = 32 4310

12 Octal to Decimal Decimal Octal Binary Hexadecimal

13 Octal to Decimal Technique
Multiply each bit by 8n, where n is the “weight” of the bit The weight is the position of the bit, starting from 0 on the right Add the results

14 Example 7248 => 4 x 80 = x 81 = x 82 =

15 Hexadecimal to Decimal
Octal Binary Hexadecimal

16 Hexadecimal to Decimal
Technique Multiply each bit by 16n, where n is the “weight” of the bit The weight is the position of the bit, starting from 0 on the right Add the results

17 Example ABC16 => C x 160 = 12 x 1 = B x 161 = 11 x 16 = A x 162 = 10 x 256 = 2560 274810

18 Decimal to Binary Decimal Octal Binary Hexadecimal

19 Decimal to Binary Technique Divide by two, keep track of the remainder
First remainder is bit 0 (LSB, least-significant bit) Second remainder is bit 1 Etc.

20 Example 12510 = ?2 12510 =

21 Octal to Binary Decimal Octal Binary Hexadecimal

22 Octal to Binary Technique
Convert each octal digit to a 3-bit equivalent binary representation

23 Example 7058 = ?2 7058 =

24 Hexadecimal to Binary Decimal Octal Binary Hexadecimal

25 Hexadecimal to Binary Technique
Convert each hexadecimal digit to a 4-bit equivalent binary representation

26 Example 10AF16 = ?2 A F 10AF16 =

27 Decimal to Octal Decimal Octal Binary Hexadecimal

28 Decimal to Octal Technique Divide by 8 Keep track of the remainder

29 Example = ?8 8 19 2 8 2 3 8 0 2 = 23228

30 Decimal to Hexadecimal
Octal Binary Hexadecimal

31 Decimal to Hexadecimal
Technique Divide by 16 Keep track of the remainder

32 Example = ?16 77 2 16 = D 0 4 = 4D216

33 Binary to Octal Decimal Octal Binary Hexadecimal

34 Binary to Octal Technique Group bits in threes, starting on right
Convert to octal digits

35 Example = ?8 = 13278

36 Binary to Hexadecimal Decimal Octal Binary Hexadecimal

37 Binary to Hexadecimal Technique Group bits in fours, starting on right
Convert to hexadecimal digits

38 Example = ?16 B B = 2BB16

39 Octal to Hexadecimal Decimal Octal Binary Hexadecimal

40 Octal to Hexadecimal Technique Use binary as an intermediary

41 Example 10768 = ?16 E 10768 = 23E16

42 Hexadecimal to Octal Decimal Octal Binary Hexadecimal

43 Hexadecimal to Octal Technique Use binary as an intermediary

44 Example 1F0C16 = ?8 1 F C 1F0C16 =

45 Exercise – Convert ... Decimal Binary Octal Hexa- decimal 33 1110101
703 1AF Don’t use a calculator! Skip answer Answer

46 Exercise – Convert … Decimal Binary Octal Hexa- decimal 33 100001 41
Answer Decimal Binary Octal Hexa- decimal 33 100001 41 21 117 165 75 451 703 1C3 431 657 1AF

47 Common Powers (1 of 2) Base 10 Power Preface Symbol pico p nano n
10-12 pico p 10-9 nano n 10-6 micro 10-3 milli m 103 kilo k 106 mega M 109 giga G 1012 tera T Value .001 1000

48 Common Powers (2 of 2) What is the value of “k”, “M”, and “G”?
Base 2 Power Preface Symbol 210 kilo k 220 mega M 230 Giga G Value 1024 What is the value of “k”, “M”, and “G”? In computing, particularly w.r.t. memory, the base-2 interpretation generally applies

49 Example In the lab… 1. Double click on My Computer 2. Right click on C: 3. Click on Properties / 230 =

50 Exercise – Free Space Determine the “free space” on all drives on your personal computer! Drive Free space Bytes GB A: C: D: E: etc.

51 Binary Addition (1 of 2) Two 1-bit values A B A + B 1 10 “two”

52 Binary Addition (2 of 2) 10101 21 + 11001 + 25 101110 46
Two n-bit values Add individual bits Propagate carries E.g., 1 1

53 Multiplication (1 of 3) Decimal (just for fun) 35 x

54 Multiplication (2 of 3) Binary, two 1-bit values A B A  B 1

55 Multiplication (3 of 3) Binary, two n-bit values As with decimal values E.g., Exercise- Search about binary division? x

56 Fractions Decimal to decimal (just for fun)
3.14 => 4 x 10-2 = x 10-1 = x 100 =

57 Fractions Binary to decimal
=> 1 x 2-4 = x 2-3 = x 2-2 = x 2-1 = x 20 = x 21 =

58 Fractions Decimal to binary 3.14579 11.001001...
x x x x x x etc.

59 Exercise – Convert ... Decimal Binary Octal Hexa- decimal 29.8
3.07 C.82 Don’t use a calculator! Skip answer Answer

60 Exercise – Convert … Decimal Binary Octal Hexa- decimal 29.8
Answer Decimal Binary Octal Hexa- decimal 29.8 35.63… 1D.CC… 5.8125 5.64 5.D 3.07 3.1C 14.404 C.82

61 Signed Binary number Sign-magnitude 1’s Complement 2’s Complement
In all the three methods, the left digit for the positive numbers is zero and for the negative numbers is one! .... Sign bit n - 1

62 Sign-magnitude The left bit is the sign Positive numbers
Negative numbers 0000=+0 1000=-0 0001=+1 1001=-1 0010=+2 1010=-2 0011=+3 1011=-3 0100=+4 1100=-4 0101=+5 1101=-5 0110=+6 1110=-6 0111=+7 1111=-7

63 Sign-magnitude(cont.)
For a number with n bits: the biggest number is the smallest one is We have two values for zero: +0 and -0 Adding two numbers is not easy! ??

64 1’s Complement (r-1)’s complement of a (with n digits) is:
Positive numbers Negative numbers 0000=+0 1111=-0 0001=+1 1110=-1 0010=+2 1101=-2 0011=+3 1100=-3 0100=+4 1011=-4 0101=+5 1010=-5 0110=+6 1001=-6 0111=+7 1000=-7

65 1’s Complement to Decimal
= = - 4

66 1’s Complement(cont.) We have two values for zero: +0 and -0
Summation of two numbers: if a carrier value is generated, add it with the result Exe: What is the biggest and smallest numbers which can be represented by this method?

67 2’s Complement (r)’s complement of a (with n digits) is:
Positive numbers Negative numbers 0000=0 1111=-1 0001=+1 1110=-2 0010=+2 1101=-3 0011=+3 1100=-4 0100=+4 1011=-5 0101=+5 1010=-6 0110=+6 1001=-7 0111=+7 1000=-8

68 2’s Complement to Decimal
= – 26 = - 53

69 2’s Complement(cont.) We have one value for zero

70 Multiplication (Example 1)
Sign extension

71 Multiplication(Example 2)

72 Exercise- Search about:
How compute the 1’s complement multiplication/summation? How compute 1’s and 2’s complement division?


Download ppt "Number Systems."

Similar presentations


Ads by Google