Tutorial-1 Dr. Manideepa Mukherjee Department of CS & IS 1 Number Systems ● Digits ● Positional Notation ● Conversion 2 Digits Digit is a single numerical symbol used to represent numbers. Digits vary depending on the base of the number system. ○ ○ ○ ○ Decimal (Base 10): 0,1, 2, 3, 4,…..9 Binary (Base 2): 0, 1 Octal (Base8): 0, 1, 2, 3….,7 Hexadecimal (Base 16): 0, 1, 2, 3….…, 9, A, B, C, …F 3 Positional Notation ● Larger numbers can be constructed using positional notation. ● The position to the left of the radix (number base) point is always the units position in any number system. For example the position left to the decimal point is always 100, the position to the left of the binary point is 20, Octal point is 80. ● Units position has the power 0 and weight 1. For Example. In decimal system 100, Binary system 20, Octal system 80, Hexadecimal System 160. 4 Positional Notation ● The positions to the left of the units positions have positive powers. For example 101, 21, 81, 161. ● The positions to the right of the radix point have negative powers. Example 10-1, 2-1, 8-1, 16-1. 5 Binary Numbers Base 2, Digits 0,1. Conversion: ● Binary to decimal ● Decimal to binary 6 Conversion from Binary to Decimal Example : (101.1)2 Power 22 21 20 2-1 Weight 4 2 1 0.5 Number 1 0 1. 1 Numeric Value 4 0 1 0.5 Answer = (5.5)10 7 Conversion from Decimal To convert a decimal whole number to another number system divide the decimal number by the radix and save the remainders as the significant digits of the result. Example: Convert (68)10 to binary. 68/2 = 34 remainder is 0 34/2 = 17 remainder is 0 17/2 = 8 remainder is 1 8/2 = 4 remainder is 0 4/2 = 2 remainder is 0 2/2 = 1 remainder is 0 1/2 = 0 remainder is 1 Answer = (1000100)2 8 Conversion from Decimal To convert a decimal fraction to another number system fraction, multiplication by the radix is carried out repetitively and the integer part of the result is saved and placed after the radix point. This process can be stopped anytime when the desired accuracy is achieved. Example: Convert (0.68)10 to binary. 0.68 * 2 = 1.36 integer part is 1 Take the fractional part and continue the process 0.36 * 2 = 0.72 integer part is 0 0.72 * 2 = 1.44 integer part is 1 0.44 * 2 = 0.88 integer part is 0 Answer = (.1010)2 9 Octal Number System Digits – 0, 1, 2, …., 7 Base – 8 Conversion ● Octal to Decimal ● Decimal to Octal ● Binary to Octal and Octal to binary 10 Octal to Decimal Convert (3754)8 to decimal =(3x83 ) + (7x82 ) + (5x81 ) + (4x80 ) = 1536 + 448 + 40 + 4 = (2028)10 11 Decimal to Octal (3479)10 to Octal 3479/8 = 434 rem = 7 434/8 = 54 rem = 2 54/8 = 6 rem = 6 6/8 = 0 rem = 6 Answer = (6627)8 12 Binary to Octal and Octal to Binary Group 3 bits starting from LSB and progressing to MSB Example: Convert (11100111)2 to Octal = 011 100 111 = (3 4 7)8 Example: Convert (537)8 to Binary = (101011111)2 13 Hexadecimal Number system Base or radix 16 number system. Numbers are 0,1,2…..8,9, A, B, C, D, E, F. 1 hex digit is equivalent to 4 bits. Conversion ● Hexadecimal to Decimal ● Decimal to Hexadecimal ● Binary to Hexadecimal and Hexadecimal to Binary 14 Conversion Hexadecimal to Decimal (F4C)16 to decimal (F x 162) + (4 x 161) + (C x 160) = (15 x 256) + (4 x 16) + (12 x 1) = (3916)10 15 Conversion Decimal to Hexadecimal (3479)10 to Hexadecimal 3479/16 = 217 rem = 7 217/16 = 13 rem = 9 13/16 = 0 rem = 13 (D) Answer = (D97)16 16 Binary to Hexadecimal and Hexadecimal to Binary Grouping bits in the binary numbers into groups of four bits starting from LSB to MSB. Example: (1 1000 1010 1000 0111)2 = (0001 1000 1010 1000 0111)2 = (1 8 A 8 7)16 Example: (1BA2)16 = (0001101110100010)2 17 ASCII American Standard Code for Information Interchange (ASCII) data represent alphanumeric characters in the memory of a computer system. Developed by ANSI (American National Standards Institute) Represents ○ ○ ○ Latin alphabet, Arabic numerals, standard punctuation characters Plus small set of accents and other European special characters 7-bit code: 128 characters 18 ASCII Reference Table 1110100 Copyright 2010 John Wiley & Sons, Inc. 19 Conversion Example2: Convert (23.5)6 to Decimal. Power 61 60 6-1 Weight 6 1 0.167 Number 2 3. 5 Numeric Value 12 3 0.835 (23.5)6 = 15.835 20 Practice Problems Convert to Decimal 1. (1011.11)2 2. (5AB.C)16 3. (753.23)8 Convert from Decimal to Binary, Octal and Hexadecimal 1. 788.38 2. 0.4325 3. 9365.23 21 Conversion Problems Convert each of the following binary numbers to decimal, octal, and hexadecimal formats. (111011101)2 (10101010111)2 (111100000)2 22 THANK YOU 23