Number systems, Operations, and Codes 1- Decimal Numbers The decimal number system has ten digits . These are : 0 , 1 , 2 , 3, 4 , 5 , 6 , 7 , 8 , 9 . The decimal number system has the base = 10 Example -1- Example -2- Example -3- : Express the decimal number 897.9 as a sum of the value of each digit.
2- Binary Numbers The binary number system has two digits (bits) . These are : 0 , 1. The binary number system has the base = 2 The weight of a bit increases from right to left in a binary whole number
Decimal to Binary Conversion Method : To get the binary number for a given decimal number , divide decimal number by 2 until the quotient is 0 . Remainders form the binary number . Example -1- Example -2- : convert the following decimal numbers into binary : 19 - 45
Binary to Decimal Conversion Method : Add the weights of all “1”s in a binary number to get the decimal values Example -1- Example -2- Example -3- : convert the following binary numbers 10101110 , 11.011101 into decimal number ?
Convert Decimal Fraction to binary Method : Repeated multiplication by 2 until fractional part is zero Example -1- Example -2- : convert the following decimal numbers into binary : 0.375 0.559
3- Octal Numbers The Octal number system has 8 digits. These are : 0 , 1, 2 , 3, 4 , 5 , 6, 7 The Octal system has the base = 8 Assignment: How could we convert Octal to decimal ? give an example . How could we convert Decimal to Octal ? give an example . How could we convert Binary to Octal ? give an example . How could we convert Octal to Binary ? give an example .
Convert Decimal to Octal Divide the given decimal number by base 8 and write the reminders starting first reminder from right to left Example: (57)10 = (?)8 Answer: (71)8 Or using polynomial of weights, like: … 83 82 81 80 512 64 8 1 Example: (413)10 = 0 6 3 5 Where: (635)8 = 5.80 + 3.81 + 6.82 = 5.1 + 3.8 + 6.64 = 5 + 24 + 384 = (413)10
4- Hexadecimal Numbers The hexadecimal number system has 16 digits. These are : 0 , 1, 2 , 3, 4 , 5 , 6, 7 , 8 , 9, A , B , C , D , E , F The hexadecimal system has the base = 16
Convert Decimal to Hexadecimal Divide the given decimal number by base 16 and write the reminders starting first reminder from right to left Example: (57)10 = (?)16 Answer: (39)16 Or using polynomial of weights, like: … 162 161 160 256 16 1 Example: (413)10 = 1 9 D Where: (19D)16 = D.160 + 9.161 + 1.162 = 13.1 + 9.16 + 1.256 = (413)10
Convert between different Number systems Base of binary system is 2 = 21 Base of Octal System is 8 = 23 Base of Hexadecimal system is 16 = 24 It means each Hexadecimal digit ~ 4 binary digits, and each Octal digit ~ 3 binary digits Examples: Convert the binary value 110011000101100 To the corresponding Octal and hexadecimal value 110 011 000 101 100 = 63054 Octal 110 0110 0010 1100 = 662C Hexadecimal!
Hexadecimal Numbers (cont.) Binary to hexadecimal Method: Break the binary number into 4-bit groups starting at the right-most bit , Then: Replace each 4-bit group with the equivalent hexadecimal symbol.
Hexadecimal Numbers (cont.) hexadecimal to Binary Method : Replace each hexadecimal symbol with the appropriate four bits.
Hexadecimal Numbers (cont.) hexadecimal to Decimal Method Convert the hexadecimal to binary then convert from binary to decimal.
Hexadecimal Numbers (cont.) Decimal to hexadecimal Method : Repeated division of a decimal number by 16 .
Arithmetic Operations 1st and 2nd Complement 1st complement : Method : Invert each bit to get the 1st complement Example -1- Example -2- : Determine the first complement of the following binary 00011010 - 11110111 - 10001101 2nd complement : Method -1- : 2nd complement = 1st complement + 1 Example -1-
Arithmetic Operations 1st and 2nd Complement (cont.) Method -2- : Change all the bits to the left of the least significant 1 to gets the 2nd complement Example -1- : Determine the 2nd complement of the following binary 00010110 - 11111100 - 10010001 Application Example