Principles Of Digital Design Discussion: Numbers Binary to Decimal Conversion Decimal to Binary Conversion Floating-Point Conversion
Positional Number System Each number is represented by a string of digits, in which the position of each digit has an associated weight 1234.56 10 = 1 ∙ 10 3 + 2 ∙ 10 2 + 3 ∙ 10 1 + 4 ∙ 10 0 + 5 ∙ 10 -1 + 6 ∙ 10 -2 1101.11 2 = 1 ∙ 2 3 + 1 ∙ 2 2 + 0 ∙ 2 1 + 1 ∙ 2 0 + 1 ∙ 2 -1 + 1 ∙ 2 -2 DIGITAL DESIGN 101, University of California Numbers
Binary to Decimal Conversion Multiply and Add 1101.11 2 = 1 ∙ 2 3 + 1 ∙ 2 2 + 0 ∙ 2 1 + 1 ∙ 2 0 + 1 ∙ 2 -1 + 1 ∙ 2 -2 = 8 + 4 + 0 + 1 + ½ + ¼ = 13.75 DIGITAL DESIGN 101, University of California Numbers
Decimal to Binary Conversion Divide/multiply by 2 and concatenate remainders 13.75 10 = 1101.11 2 = (1 ∙ 2 3 + 1 ∙ 2 2 + 0 ∙ 2 1 + 1 ∙ 2 0 ) + (1 ∙ 2 -1 + 1 ∙ 2 -2 ) = ( 1 ∙ 2 3 + 1 ∙ 2 2 + 0 ∙ 2 1 + 1 ∙ 2 0 ) + ( 1 ∙ 2 -1 + 1 ∙ 2 -2 ) 13.75 10 : 2 = 6 + 1 6.75 : 2 = 3 + 0 3.75 : 2 = 1 + 1 1.75 : 2 = 0 + 1 -------------------------------- 0.75 x 2 = 1 + 0.5 0.5 x 2 = 1 + 0.0 DIGITAL DESIGN 101, University of California Numbers
Floating-Point Review General form +/- mantissa × (radix) exponent 32-bit standard 0 1 9 31 Excess-127 Normalized Sign characteristic Fraction Implied binary point Sign: 0 for + and 1 for – Exponent = characteristic – bias where bias = (radix s /2 ) – 1 therefore, bias is (2 7 -1=127) for 32-bit floating point binary number Mantissa = 1.(normalized fraction) DIGITAL DESIGN 101, University of California Numbers
Floating-Point Binary to Decimal Problem: Convert a 32-bit floating-point number to decimal 1 01111100 10110000000000000000000 0 1 9 31 Excess-127 Normalized Sign characteristic Fraction Implied binary point Procedure: 1. Determine sign, mantissa and exponent Sign = Negative Exponent = characteristic – bias = 01111100 2 -127 = 124 – 127 = -3 Mantissa = 1.1011 2 = 1.6875 10 2. Result = mantissa × (radix) exponent = -1.1011 2 × 2 -3 (-1.6875 × 2 -3 ) DIGITAL DESIGN 101, University of California Numbers
Recommend
More recommend