1. Number System Digital Logic and Computer Design by Ravinder Nath Rajotiya - September 17, 2022September 17, 20220 Share on Facebook Share Send email Mail Print Print Table of Contents Toggle What is a Number?Number SystemsNumber System ChartRange of Numbers in a number systemConversion of numbers to other base systemsProcedure of converting a given decimal number to any other number system by:Binary to Octal:Octal to BinaryHexadecimal to BinaryConversion of Fraction numbers1. Converting Decimal to BinaryConverting any base fraction to decimal numberBCDConverting Given BCD to its BinaryWeighted / Non-Weighted CodesWeighted codeNon-Weighted Codes:Excess-3 (XS-3)Gray Code:Reflective Codes/Self Complementary CodesSequential CodeAlphanumerical codesNumber System Questions What is a Number? A number is a mathematical value used for counting or measuring or labelling objects. In number system these numbers are used as digits. Number Systems A number system is the mathematical notation for representing numbers of a given set by using digits or other symbols in a consistent manner. It provides a unique representation of every number and represents the arithmetic and algebraic structure of the figure. The value of any digit in a number can be determined by: The digit Its position in the number The base of the number system Number System Chart There are various types of number systems in mathematics. The four most common number system types are: Decimal number system (Base- 10) Binary number system (Base- 2) Octal number system (Base-8) Hexadecimal number system (Base- 16) Numbers are used to represent data, and the different the data is representation are: 1’s complement 2’s complement 9’s complement 10’s complement Range of Numbers in a number system Binary (base 2) Octal (base 8) Decimal (base 10) Hexadecimal (base 16) Decimal Equivalent 0 0 0 0 0 1 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 9 9 9 A 10 B 11 C 12 D 13 E 14 F 15 Conversion of numbers to other base systems Decimal to any other number system From any other number system to decimal system Procedure of converting a given decimal number to any other number system by: Step-1: Divide the decimal number to be converted by the value of the base of the number in which conversion is required Step-2: get the remainder from step-1 as the rightmost digit (LSD) of new base number Step-3: Divide the quotient of the previous step with the base value of required system Step-4: Record the remainder as the next higher digit of the new base number Repeat step-3 and step-4 till the quotient become zero. Example-1: Convert decimal (19)10 to binary. Example-2: Convert decimal (619)10 to octal number. Conversion from other base number system to decimal number system We follow the sum of the weighted position of each digit by: Step-1: Determine the positional value of the each digit(It depends on the position and the base of the given number. Step-2: Multiply the column values (in step-1) by the corresponding column digit Step-3: Sum the product (values obtained in step-2). The total is the equivalent value in decimal number system. Example-3: Convert octal (1250)8 to decimal number system. Solution: Conversion from Other Base Number System to Non-decimal Number System Follow the given below steps for Conversion from Other Base Number System to Non-decimal Number System. Step-1: Convert the given number to the decimal number system Step-2: Now convert the decimal number so obtained to the required number system as described above. Example-4 : Convert (1001)2 = ( ? )3. Solution hint: Step-1: convert (1001)2 to decimal answer here is decimal 9 Step-2 : convert decimal 9 to ternary with base 3 by division process, answer here will be (100) 3. Therefore (1001)2 = (100) 3. Binary to Octal: Conversion Process Beginning from right make group of three bits and write their corresponding octal value below it. Add as many zeros at the left most to complete the group of three bits. Read the number so obtained to be answer in octal. Example: Convert binary 010101011111101 to octal Solution Make groups 010 101 011 111 101 Write digits 2 5 3 7 5 Answer is (25375)8 Octal to Binary For each octal digit write its equivalent three bit binary code Read the code so obtained from left to right Example: Convert (5245)8 to binary Solution: 5 2 4 5 101 010 100 101 Answer is (101010100101)2 Problems for Practice: (1100101)2 = ( ? )8. (246753)8 = ( ? )2. Binary to Hexadecimal: Conversion Process Beginning from right make group of four bits and write their corresponding hex value below it. Add as many zeros at the left most to complete the group of four bits. Read the number so obtained to be answer in Hexadecimal. Example : Convert (110101110110001110)2 to hexadecimal Make group of 4-bits 11 0101 1101 1000 1110 Add zeros in front 0011 0101 1101 1000 1110 Write hex digits 3 5 C 8 E Answer is = (35C8E)16. Hexadecimal to Binary For each Hex digit write its equivalent four bit binary code Read the code so obtained from left to right to be binary equivalent of hexadecimal. Example: Convert (A6B9)16 to its binary Solution: (A6B9)16 A 6 B 9 1010 0110 1011 1001 (A6B9)16 = (1010011010111001)2. Problems for Practice: (10010111011000100110111)2 = ( ? )16. (FA2953B)16 =( ? )2. Conversion of Fraction numbers 1. Converting Decimal to Binary Fraction number is converted to its equivalent in base ‘X’ by following the multiplication by the base of number to which conversion is to be done. Procedure: a). Multiply the given decimal fraction by 2 b). Write the integer to the right and take fraction part to next multiplication c) Repeat step-(a) and step-(b) till the required number of decimal places. d). Read all integers from top to the bottom; i.e. integer value of first multiplication will be 1st digit after decimal point. Example: Convert (0.545)10 to binary to a precession of 4 decimal places Solution Fraction x base Product Integer 0 .545 x 2 = 1.090 —Keep Integer-à 1 0.090 x 2 = 0.180 —Keep Integer-à 0 0.180 x 2 = 0.360 —Keep Integer-à 0 0.360 x 2 = 0.720 —Keep Integer-à 0 0.720 x 2 = 1.440 —Keep Integer-à 1 Answer is 0.545)10 = (0.10001)2. Converting any base fraction to decimal number We can easily convert a fraction number in any base system to its decimal equivalent using the positional weight system. Remembering that the powers of the base starts with -1 and goes as -2, -3 for the subsequent digits Procedure Step-1: After the decimal point, write the weights of each digit/ or bit Step-2: Multiply the weights by the corresponding column digit Step-3: Add all products so obtained. Example : Convert (0.254)8 in octal to its decimal equivalent fraction Solution: Given Number 0 . 2 5 4 Weights 0 . 2-1 2-2 2-3. Multiply by digit . 2×8-1 5×8-2 4×8-3 Add all product . 2×0.125 + 5×0.015625 + 4×0.001953125 = 0.25 + 0.078125 + 0.0078125 Answer = (0.3359375)10. Rounding to 4 decimal places = (0.3359)10 Brain storming problem: 1. If (2.3)4 + (1.2)4 = ( Y )4 what is the value of Y Solution: Since base is common on the LHS, we can add the numbers. Remember in base 4, the values are 0,1,2,3. So while adding if sum > 3 carry will be generated. Watch the solution carefully. 3+2 =5, but in base 4, we get 1, with carry of 1 Also now see the integer value of answer, it is 4, this is not a valid digit. 4 in base 4 = 10 So final answer = (2.3)4 + (1.2)4 = ( 10.1 )4 Example-6: Given (135)x + (144)x = (323 )x what is the base of the system. Options: (a) 5 (b) 3 (c) 12 (d) 6 Solution: Highest Digits given on LHS and RHS is 5; so the base of the system can be >=6, Let us verify by doing the sum of LHS 135 144 ——– X X9 the least digit is 9, but look carefully digit 9 is not present in answer on RHS of the given question. The right choice is (d) Method-2 Practice Problems Consider the equation (43)x = (Y3)8 where X and Y are unknown. The number of possible solutions to X and Y is ……. BCD BCD Stands for binary coded decimal, BCD numbers are used in computer system instead of the conventional decimal system. The advantage of BCD over decimal system is the ease of conversion from BCD to binary. As in conventional decimal each digit is represented by 4-binary bits. There are 16 possible combination that can be written with 4-bits. But BCD has only 10-digits 0 through 9, All combinations from 10 to 15 are therefore invalid in BCD. The table below shows the decimal digits, its binary and BCD equivalent Decimal Numbers Binary BCD 0 0000 0000 1 0001 0001 2 0010 0010 3 0011 0011 4 0100 0100 5 0101 0101 6 0110 0110 7 0111 0111 8 1000 1000 9 1001 1001 10 1010 X 11 1011 X 12 1100 X 13 1101 X 14 1110 X 15 1111 X Converting Given BCD to its Binary Conversion of BCD to binary is straight forward. Procedure – Just write the 4-bit binary equivalent of each digit below it. That’s all. Example: Convert BCD 568 to its binary equivalent Solution: 5 6 8 0101 0110 1000 So, BCD 568 = 010101101000 Weighted / Non-Weighted Codes Weighted code Weighted code obey the positional weight principle where each position of the digit represent specific weight. There are several system of codes which are used to express the decimal digits 0 through 9. These digits are represented by a group of 4-bits. As an example each digit of the number 246 is represented as group of 4-bits as shown in figure. The weights corresponding to each bit is also shown. Non-Weighted Codes: Example of such codes are XS-3 and the Gray code Excess-3 (XS-3) It is non-weighted code used to represent decimal numbers. The codes in this system are derived by adding 3 to the 8421 BCD code of digits. Table of 8421 BCD and their equivalent XS-3 codes Decimal Digit 8421 BCD code XS-3 code 0 0000 0011 1 0001 0100 2 0010 0101 3 0011 0110 4 0100 0111 5 0101 1000 6 0110 1001 7 0111 1010 8 1000 1011 9 1001 1100 Gray Code: Gray code is also called as a unit distance code. There is only 1-bit change in the code as the number is incremented or decremented by 1. These code does not support any arithmetic operations. This code is also a cyclic code Table below shows the gray code of the decimal numbers As can be seen in the Gray Code column-3 code of 0à 00; 1à 01; 2à 11; 3à10, exactly 1-bit change from one digit to next or previous.So is also for 3-bit and 4-bit codes. The position of bit that changes has been highlighted by green arrows. Example- 1.. Decimal equivalent of XS-3 number 110010100011.01110101 is (a) 970.42 (b) 861.75 (c) 1253.75 (d) None 2. The decimal number 10 is represented in BCD form as (a) 01010 (b) 001010 (c) 00010000 (d) 1010 3. A three digit number requires…………….for representation in conventional BCD form (a) 24-bits (b) 6 bits (c) 12 bits (d) 3 bits Reflective Codes/Self Complementary Codes A code is called reflective when the code is self-complementary. Examples of self-complementary or reflective code are 8421 BCD, 2421 BCD and 5421 BCD and XS-3. Figure below shows how the reflective/self-complementary code are called so. Sequential Code In sequential code we get the next or the previous number by adding or subtracting 1 from the number. Here each succeeding code is one binary number greater than its preceding number. This property of the number helps in manipulating the data. Example of such code is 8421 BCD and XS-3 code. Alphanumerical codes · ASCII – American standard code for information interchange · EBCDIC- Extended Binary coded decimal interchange code · Five-bit Baudot Code Number System Questions Convert (543)10 into hexadecimal. [Answer: (21F)16] Convert 0.525 into an octal number. [Answer: 4146] What is binary equivalent of BCD number 5920. [Answer: 0101100100100000] Gray code is also known as a ……………….code (Answer:unit distance code] Octal number is an example of the ……………..number [Answer: Weighted] ……………………are an example of Non-weighted code [Answer: XS-3 and Gray code] What is XS-3 code of BCD 5679 [Answer: 1000 1001 1010 1100] What is decimal equivalent of XS-3 1011110010001010. {Answer: 1000 1001 0101 0111] What is binary equivalent of 2475 octal number. [Answer: 010 100 111 101] Convert hexadecimal 2FB5A to its octal equivalent [Answer: 0575532 ] Share on Facebook Share Send email Mail Print Print