Download presentation
Presentation is loading. Please wait.
1
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Number systems
2
Introduction There are several number systems which we normally use, such as decimal, binary, octal, hexadecimal. These systems are classified according to the values of the base of the number system. Base is total number of digits in the number system.
3
Introduction The maximum value of a single digit is always equal to one less than the value of the base. The number systems having base 16, 10, 8 and 2 are called hexadecimal, decimal, octal and binary number systems respectively.
4
Decimal Number System The decimal number system is a base-10 number system and therefore has 10 different digits. These are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Each position of the digit represents a specific power of the base (10). We use this number system in our day to day life.
5
Decimal Number System For example, for decimal number , the integer part (i.e. 2785) can be expressed as and fractional part can be expressed as
6
Binary Number System The binary number system is a base-2 number system with ‘0’ and ‘1’ as the two independent digits. The maximum value of a single digit is 1 (one less than the value of the base) Each position of a digit represents a specific power of base 2. This number system is used in computers.
7
Binary Number System Example
With two symbols for each bit, we have 2n possible combinations of symbols where n is the number of bits.
8
A bit Nibble Byte Word Binary Number System
Stands for binary digit is a single place or position in a binary number. A bit A four bit binary number. Nibble An eight bit (2 nibble) binary number. Byte Is a string of bits whose size (the word length) may be equal to one byte, two bytes, four bytes and more. Word
9
Binary Number System The rightmost bit, the one that represents the ones place, is called the Least Significant Bit or LSB. The leftmost bit, the one that represents the highest power of two represented by that number, is called the Most Significant Bit or MSB
10
Octal Number System The octal number system has a base of 8 and therefore has eight distinct digits. All higher-order numbers are expressed as a combination of these on the same pattern as the one followed in the case of the binary and decimal number systems. The independent digits are 0, 1, 2, 3, 4, 5, 6 and 7. Each position of a digit represents a specific power of the base 8.
11
Octal Number System Since there are only 8 digits, 3 bits are sufficient to represent any octal number in binary. Example
12
Hexadecimal Number System
The hexadecimal number system is a base-16 number system this means it has 16 basic digits which are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. The symbols A, B, C, D, E and F represent the decimal number 10, 11, 12, 13, 14 and 15 respectively. Each position of a digit represents a specific power of the base 16.
13
Hexadecimal Number System
Since there are only 16 digits, 4 bits are sufficient to represent any hexadecimal number in binary. Example
14
Converting a Decimal No. to a No. of Another Base
Division Reminder Method Divide the decimal number to be converted by the value of the new base. Record the reminder from step 1 as the rightmost digit of the new base number Divide the quotient of the previous divide by the new base. Record the reminder from step 3 as the next digit of the new base number.
15
Converting a Decimal No. to a No. of Another Base
Division Reminder Method Repeat step 3 and 4 recording reminders from right to left until the quotient become zero in step 3. Note that the last reminder thus obtained will be the most significant digit of the new base number.
16
Converting a Decimal No. to a No. of Another Base
Decimal-to-binary Conversion Conversion of decimal to a binary number can be done by dividing the decimal number by 2 repeatedly, until the quotient of zero is obtained.
17
Converting a Decimal No. to a No. of Another Base
Decimal-to-binary Conversion Example 1.1. Convert 2610 into a binary number
18
Converting a Decimal No. to a No. of Another Base
Decimal-to-octal Conversion Conversion of decimal to a Octal number can be done by dividing the decimal number by 8 repeatedly, until the quotient of zero is obtained.
19
Converting a Decimal No. to a No. of Another Base
Decimal-to-octal Conversion Example 2. Convert into an octal number.
20
Converting a Decimal No. to a No. of Another Base
Decimal-to-hexadecimal Conversion Conversion of decimal to a Hexadecimal number can be done by dividing the decimal number by 16 repeatedly, until the quotient of zero is obtained.
21
Converting a Decimal No. to a No. of Another Base
Decimal-to-hexadecimal Conversion Example 3. Convert into a hexadecimal number.
22
Converting a Decimal No. to a No. of Another Base
Method Determine the column (positional) value of each digit Multiply the obtained column values by the digits in the corresponding columns Calculate the sum of these products
23
Conversion Between Number Systems
Binary-to-decimal Conversion Example: Convert into a decimal number
24
Conversion Between Number Systems
Octal-to-decimal Conversion Example: Convert (137.21)8 into a decimal number
25
Conversion Between Number Systems
Hexadecimal-to-decimal Conversion Example: Convert (1E0.2A)16 into a decimal number
26
Converting a number of some base to a number of another base
Method Convert the original number to a decimal number (base 10) Convert the decimal number to the new base number.
27
Converting a number of some base to a number of another base
Example
28
Converting a number of some base to a number of another base
Example
29
Shortcut method for converting a binary number to its equivalent octal number
Divide the digits into groups of three starting from the right Convert each group of three binary digits to one octal digit using the method of binary to decimal conversion
30
Shortcut method for converting a binary number to its equivalent octal number
Binary–Octal Conversions Example: Convert ( )2 into an equivalent octal number
31
Shortcut method for converting a octal number to its equivalent Binary number
Convert each octal digit to a 3 digit binary number ( the octal digits may be treated as decimal for this conversion). Combine all the resulting binary groups (of 3 digits each) into a single binary number.
32
Shortcut method for converting a octal number to its equivalent Binary number
Example: Convert into an equivalent binary number.
33
Shortcut method for converting a binary number to its equivalent Hexadecimal number
Divide the digits into groups of four starting from the right Convert each group of three binary digits to one hexadecimal digit.
34
Shortcut method for converting a binary number to its equivalent Hexadecimal number
Example: Convert into an equivalent hexadecimal number.
35
Shortcut method for converting a Hexadecimal number to its equivalent Binary number
Convert the decimal equivalent of each hexadecimal digit to a 4 digit binary number. Combine all the resulting binary groups (of 4 digits each) into a single binary number.
36
Shortcut method for converting a Hexadecimal number to its equivalent Binary number
Example: Convert 9E.AF216 into an equivalent binary number.
37
Conversion from an Octal to Hexadecimal Number and Vice Versa
Method to convert an octal number into a hexadecimal number. First convert the octal number to its binary equivalent. Then form groups of 4 bits, starting from the LSB. Then write the equivalent hexadecimal number for each group of 4 bits.
38
Conversion from an Octal to Hexadecimal Number and Vice Versa
Method to converting a hexadecimal number into an octal number: First convert the hexadecimal number to its binary equivalent. Then form groups of 3 bits, starting from the LSB. Then write the equivalent octal number for each group of 3 bits.
39
Conversion from an Octal to Hexadecimal Number and Vice Versa
Example: Convert the 4.BF85 hexadecimal numbers into equivalent octal
40
Conversion from an Octal to Hexadecimal Number and Vice Versa
Example: Convert (36.532)8 into an equivalent hexadecimal number
41
Computer Arithmetic
42
Complement of a Number Binary Number System
The 1’s complement of a binary number is obtained by complementing all its bits, i.e. by replacing 0s with 1s and 1s with 0s. For example, the 1’s complement of ( )2 is ( )2. The 2’s complement of a binary number is obtained by adding ‘1’ to its 1’s complement. The 2’s complement of ( )2 is ( )2
43
Complement of a Number Decimal Number System
In the decimal number system, we have the 9’s and 10’s complements. The 9’s complement of a given decimal number is obtained by subtracting each digit from 9. For example, the 9’s complement of (2496)10 would be (7503)10 The 10’s complement is obtained by adding ‘1’ to the 9’s complement. The 10’s complement of (2496)10 is (7504)10
44
Complement of a Number Octal Number System
In the octal number system, we have the 7’s and 8’s complements. The 7’s complement of a given octal number is obtained by subtracting each octal digit from 7. For example, the 7’s complement of (562)8 would be (215)8. The 8’s complement is obtained by adding ‘1’ to the 7’s complement. The 8’s complement of (562)8 would be (216)8.
45
Complement of a Number Hexadecimal Number System
The 15’s and 16’s complements are defined with respect to the hexadecimal number system. The 15’s complement is obtained by subtracting each hex digit from 15. For example, the 15’s complement of (3BF)16 would be (C40)16. The 16’s complement is obtained by adding ‘1’ to the 15’s complement. The 16’s complement of (2AE)16 would be (D52)16
46
Integer Representation
In binary number system arbitrary numbers can be represented with just digits 0 and 1, the minus sign and the period the radix. For the purpose of computer storage and processing minus sign and periods are not used. Only binary digits may be used to represent numbers.
47
Integer Representation
Signed magnitude representation The most significant (leftmost) bit in the word is treated as the sign bit. If the sign bit is 0, the number is positive and if the sign bit is 1 the number is negative.
48
Integer Representation
Signed magnitude representation This makes it vital to declare the number of bits that a signed binary number uses. If this information is not given, then the computer or the user looking at a binary number will not know which bit is the MSB. In other words, the leading zeros of a binary value may have been removed making it look like the binary value is negative since it starts with a one.
49
Integer Representation
Signed magnitude representation Since computers don't use an infinite number of bits to represent values, the software must know two things before it can interpret a binary value: the number of bits and the type of binary representation being used.
50
Binary Arithmetic Information is handled in a computer by electronic or electrical components. Electronic components operate in binary mode (can only indicate two states, on (1) or off (0). Binary number system has only two digits (0 and 1) and is suitable for expressing two possible states.
51
Binary Arithmetic In binary system, computer circuits only have to handle two binary digits rather than ten decimal digits causing Simpler internal circuit design Less expensive More reliable circuits Arithmetic rules or processes are possible with binary numbers
52
Binary Arithmetic Examples of few devices that work in binary Mode
53
Binary Arithmetic Binary Addition
The rules of binary addition are given in Table Example: Add the binary numbers: (a) 1010 and 1101 (b) 0110 and 1111 (c) and 11011 AUGEND ADDEND SUM CARRY RESULT 1 10
54
Binary Arithmetic Binary Subtraction
The rules of binary subtraction are given in Table MINUEND SUBTRAHEND DIFFERENCE BORROW 1
55
Binary Arithmetic Binary Subtraction Direct method Subtraction
1’s Complement 2’s Complement
56
Binary Arithmetic The direct method
Example 1: Using the direct method to perform the subtraction 1000 – 1001.
57
Binary Arithmetic The direct method
When the minuend is smaller than the subtrahend the result of subtraction is negative and in the direct method the result obtained is in 2’s complement form. So to get back the actual result we have to perform the 2’s complement again on the result thus obtained.
58
Binary Arithmetic Subtraction Using 1’s Complement
Find 1’s complement of the of the number you are subtracting (subtrahend). Add this to the number from which you are taking away (minuend) If a carry is generated, remove the carry, add it to the result, if there is no carry recomplement the sum and attach a negative sign.
59
Binary Arithmetic Subtraction Using 1’s Complement
Example: Subtract (1001)2 from (1101)2 and (1100)2 from (1001)2 using the 1’s complement method.
60
Binary Arithmetic Subtraction Using 2’s Complement
Find 2’s complement of the of the number you are subtracting (subtrahend). Add this to the number from which you are taking away (minuend) If a carry is generated, discard the carry. If there is no carry take the 2’s complement of the number and change the sign.
61
Binary Arithmetic Subtraction Using 2’s Complement
Example: Subtract (1010)2 from (1001)2 using the 1’s complement method.
62
Binary Arithmetic Binary Multiplication
The rules of binary multiplication are given in Table MULTIPLICAD MULTIPLIER RESULT 1
63
Binary Arithmetic Binary Multiplication
Example: Multiply the following binary numbers and 1101.
64
Binary Arithmetic Binary Division
The rules regarding binary division are listed in Table. DIVIDEND DIVISOR RESULT Not allowed 1
65
Binary Arithmetic Binary Division
Example: Divide the following binary numbers: (a) and 101
66
Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.