Spring 2015 Week 9 Module 48 Digital Circuits and Systems Number Representation Shankar Balachandran* Associate Professor, CSE Department Indian Institute of Technology Madras *Currently a Visiting Professor at IIT Bombay Positional Number System – a review Value of a number is determined by a weighted sum of its digits Weighting is implicit and is determined for each digit by the position of the digit in the number Let the number have n digits to the left of the radix point and m digits to the right of the radix point. Di is the ith digit, R is the radix or base of the number,V is the value of the number. n 1 V Di R i n digits m digits i m Example : 12.3410 4 10 2 3 10 1 2 100 1 101 Other common radices – binary (2), octal (8), hexadecimal/hex (16): 0-9,a,b,c,d,e,f. Number Representation 2 Representation of Signed Numbers How to represent positive and negative integers using 1’s and 0’s of the binary notation ? In mathematics, there are infinitely many positive and negative integers. However, in a practical hardware system only a fixed number of integers can be represented. In most modern computer systems, numbers are represented in 32 bits. If an arithmetic operation results in a number outside the range, an overflow occurs. There are 4 popular schemes for representing signed numbers. 1. Sign Magnitude 2. Ones Complement 3. Twos Complement 4. Excess-B or Biased Representation Number Representation 3 Sign Magnitude Representation Use MSB as a sign bit as follows, MSB = 0 for positive integers MSB = 1 for negative integers S Magnitude (n-1 bits) n bits Other bits encode magnitude of integer. 2 n 1 X 2 n 1 Range of representation with n bits is: The range is symmetric around 0. There are two representations for 0, i.e., 0000 and 1000. Examples: Assume a 4-bit representation, 5 -5 3 -7 = = = = Convert the following sign magnitude numbers to a 6-bit representation. 0101 1101 0011 1111 0101 = 000101 1010 = 100010 Number Representation 4 Ones Complement Representation Positive integers are represented “as is”. Negative integers are represented by performing bit-wise complement of the integer. E.g., 5 = 0101 -5 = 1010 All positive integers have MSB=0; negative integers have MSB=1 Range of representation with n bits is: 2 n 1 X 2 n 1 The range is symmetric around 0. There are two representations for 0, i.e., 0000 and 1111. Examples: Assume a 5-bit representation, 01110 = 14 10111 = -8 15 = 01111 16 = not with 5 bits -16 = not with 5 bits Convert the following signed numbers to a 8-bit representation. Number Representation 01011 = 00001011 10111 = 11110111 5 Twos Complement Representation Positive integers are represented “as is”. Negative integers are formed by subtracting magnitude of negative integer from 0; borrowing from imaginary position to the left of MSB. (Shortcut: bit-wise complement of the integer and add 1). Example: 5 = 0101 -5 = 0000 – 0101 = 1011 All positive integers have MSB=0; negative integers have MSB=1 Range of representation with n bits is: 2 n 1 X 2 n 1 The range is asymmetric around 0. There is only one representation for 0, i.e., 0000. Examples: Assume a 5-bit representation, 01110 = 14 10111 = -9 15 = 01111 16 = not with 5 bits -16 = 10000 Convert the following signed numbers to a 8-bit representation. Number Representation 01011 = 00001011 10111 = 11110111 6 Excess-B (or Biased) Representation Integer representations are biased by B. A signed integer X is represented by the binary number X+B Range of representation with n bits is: B X 2 n B Usually, B=2n-1 -2n-1 ≤ X < 2n-1 There is only one representation for 0, i.e., binary representation for bias B. Examples: Assume a 5-bit representation and B = 24, 10001 01100 00000 0 15 = 17 – 24 = 1 = 12 – 24 = -4 = 0 – 24 = -16 = 0 + 24 = 10000 = 15 + 24 = 11111 Number Representation 7 Important Points to Remember Given a bit vector B (bn-1 to b0), it can be “interpreted” in many ways The interpretation gives the value to the vector Example: bit vector 1111 Interpreted as unsigned it is 15 Interpreted as signed it is -7 Interpreted as 2’s complement it is -1 Mixing interpretations can be disastrous Number Representation 8 Important Points to Remember Arithmetic operations are basic operations for computers Number Representation should take Numbers in the same interpretation And produce results that are consistent in the same interpretation Circuits are usually designed so that the interpretations are consistent. Number Representation 9 Number Circle 1111 1110 0000 0001 0010 1101 0011 1100 0100 0101 1011 0110 1010 1001 1000 0111 Number Representation 10 Interpretation of 4-bit Binary Numbers Number Representation 11 End of Week 9: Module 48 Thank You Number Representation 12
© Copyright 2026 Paperzz