Download presentation

Presentation is loading. Please wait.

Published bySheldon Newingham Modified over 2 years ago

1

2
NUMBER SYSTEMS

3
The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system is 10 It is called decimal or denary

4
The BASE of a number system Computers are bi-stable devices A bi-stable device has only two possible states: ON or OFF Hence a base 2 number system is enough for such devices A base 2 number system is called binary The 2 possible digits are 0 and 1

5
The BASE of a number system An other number system used with computers is Hexadecimal The base for this system is 16 The 16 possible digits are 0 – 9 and A - F

6
The BASE of a number system SystemBaseDigits used Decimalbase 10 e.g , 1, 2, 3, 4, 5, 6, 7, 8, 9 Binarybase 2 e.g , 1 Hexadecimalbase 16 e.g. 3C 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

7
Place values The position of each number within a series of numbers is very important The position of the number determines how large it is All number bases have their place values

8
Place values In base 10, the place values are as follows: Values go up in powers of 10 as you move from left to right

9
Place values In base 2, the place values are as follows: Values go up in powers of 10 as you move from left to right

10
Binary to Decimal Conversion To convert binary numbers to decimal we need to follow these four steps: 1. Write down the place values, starting from the right hand side 2. Write each binary digit under its place value 3. Multiply each binary digit by its place value 4. Add up the total number

11
Binary to Decimal Conversion Example Convert the binary number to decimal Step 1Place values Step 2Binary digits Step 31 × 16 = 16 0 × 8 = 0 1 × 4 = 4 0 × 2 = 0 1 × 1 = 1 Step 4Decimal =21 Answer: = 21 10

12
Decimal to Binary Conversion To convert a decimal number to binary 1. Successively divide the decimal number by 2 and record the remainder 2. Use the numerator for the next division until the result of the division is 0 3. The remainder (1 or 0) of each division makes up the binary number

13
Decimal to Binary Conversion To convert a decimal number to binary 1. The remainder of the first division gives the LEAST significant bit 2. The remainder of the next division gives the NEXT bit etc. 3. This method produces the bits in reverse order - reading down the way gives the bits in order of right to left

14
Decimal to Binary Conversion Example Convert in binary with a remainder of Answer : =

15
Decimal to Binary Conversion An alternative method is to use the place values. To convert a decimal number to binary follow these steps: 1.Write down the place values up to the one which is just greater than the decimal number we need to convert

16
Decimal to Binary Conversion Let us consider the decimal number 37, we would need to write down the place values up to Place values

17
Decimal to Binary Conversion 2.Work through the place values deciding on whether to place a 1 or a 0 under the place value

18
Decimal to Binary Conversion Since 37 is less than 64 we write a 0 under the 64. We would need a 32 so we write a 1 under the Place values Binary number 01

19
Decimal to Binary Conversion This would leave us with 37 – 32 = 5. Now we are left with 5 to distribute under the other place values. Since 5 is less than 16 and 8 we write a 0 under both. We can now place a 1 under 4. This leaves us with 5 – 4 = 1. Hence we put a 0 under 2 and a 1 under Place values Binary number So =

20
The Hexadecimal (Hex) number system Base symbols: 0 – 9 & A – F Place values increase in powers of 16 The advantage of the hexadecimal system is its usefulness in converting directly from a 4-bit binary number

21
Equivalent numbers in different bases DecimalBinaryHex DecimalBinaryHex A B C D E F

22
Hex to Decimal Conversion To convert Hex numbers to decimal we need to follow these four steps: 1. Write down the place values, starting from the right hand side 2. Write each hex digit under its place value 3. Multiply each hex digit by its place value 4. Add up the total number

23
Hex to Decimal Conversion Example Convert 3CD 16 to its decimal equivalent Step 1Place value Step 2Hex3CD Step × 3 = × 12 = × 13 = 13 Step 4Decimal =973 Answer: 3CD 16 =

24
Decimal to Hex Conversion To convert a decimal number to hex Successively divide the decimal number by 16 and record the remainder Use the numerator for the next division until the result of the division is 0 The remainder of each division makes up the hex number

25
Decimal to Hex Conversion Example 1 Convert to hex Answer : = with a remainder of9 0 2

26
Decimal to Hex Conversion Example 3 Convert to hex Answer : = = 6D with a remainder of13 0with a remainder of6

27
Decimal to Hex Conversion An alternative method is to use the place values. To convert a decimal number to hex follow these steps: 1.Write down the place values up to the one which is just greater than the decimal number we need to convert

28
Decimal to Hex Conversion Let us consider the decimal number 356, we would need to write down the place values up to Place values

29
Decimal to Hex Conversion 2.Work through the place values deciding on weather to place a 0 or a value from under the place value.

30
Decimal to Hex Conversion Since 356 is less than 4096 we write a 0 under the We would need a 256 so we write a 1 under the Place values Hex number01

31
Decimal to Hex Conversion This would leave us with 356 – 256 = 100. Now we are left with 100 to distribute under the other place values. Since 100 ÷ 16 = 6 r 4 we write a 6 under 16. This leaves us with 4 ones. Hence we put a 4 under Place values Hex number0164 So =

32
Binary to Hex Conversion To convert numbers from binary to hex and vice versa, we need to use the conversion table shown below BinaryHex BinaryHex 1011B 1100C 1101D 1110E 1111F BinaryHex A

33
Binary to Hex Conversion For each digit in the hex number, write down the equivalent 4-bit binary digit. Example Convert C3 16 to its binary equivalent Answer : C3 16 = HexadecimalC3 Binary

34
Hex to Binary Conversion Divide the binary number into 4-bit groups starting from the right (LSB). If we end up with a group of less than 4 bits on the left, add 0s to fill up the required places. Then translate each group into its equivalent hexadecimal number below.

35
Hex to Binary Conversion Example Convert to hexadecimal Answer : = 2EA 16 Binary Hexadecimal2EA

36
Binary Arithmetic

37
Addition of Binary Numbers Note: = 10 which we write as 0 carry Similarly in binary: = 0 carry 1.

38
Addition of Binary Numbers Note: = 11 which we write as 1 carry Similarly in binary: = 1 carry 1.

39
Numeric Overflow Note: The number 41 cannot be represented using 5 bits since with 5 bits we can represent the range from 0 to Numeric overflow occurs if a number too large to be represented is encountered. For example a 5 bit register is used to store the decimal number 41.

40
Negative Numbers Negative numbers can be represented in binary using one of the following ways: Sign and Magnitude Codes (SM) Two's Complement (2C)

41
The Most Significant Bit is used to represent the sign of the number Sign and Magnitude Codes The other bits represent the magnitude of the number.

42
Example: Sign and Magnitude Convert 24 to Sign and Magnitude representation using an 8-bit register format. 24 In binary Using 7 bits SM O since number is positive

43
Example: Sign and Magnitude Convert - 24 to Sign and Magnitude representation using an 8-bit register format. 24 In binary Using 7 bits SM since number is negative

44
Two's Complement (2C) The bits have the same place values as binary numbers. However the Most Significant Bit is also used to represent the sign of the number.

45
Example: Two's Complement Complement 67 using a 9-bit register 67 In binary Reverse Bits Add This gives -67

46
Range for 2C Representation 1-bit register 0 represents 0 1 represents -1 2-bit register 0 0 represents represents represents represents -1 1-bit register -1, 0 2-bit register -2, -1, 0, 1 3-bit register represents represents represents represents 3 3-bit register-4, -3, -2, -1, 0, 1, 2, represents represents represents represents -1

47
Range for 2C Representation In general an N-bit register can represent binary numbers in the range - 2 N N

48
Binary Subtraction Example: Subtract 54 from Can be written as (- 54) Step 1:Check how many bits you need Therefore we are going to use 8 bits in both cases bits (range for +ve numbers is 0 …2 n-1 ) -547 bits (range for 2C numbers is 2 n-1 to + 2 n-1 -1)

49
Binary Subtraction Step 2: Convert - 54 to a 2C binary number Step 3: Convert 103 to a binary number Step 4: Add binary 103 to Overflow bit The 9th bit or overflow bit will be ignored thus the 8-bit answer is correct

50
Binary Multiplication Shifting the number left multiplies that number by 10 Decimal SystemBinary System Shifting the number left multiplies that number by = 42 x = x 2

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google