80 likes | 91 Views
This lecture module covers binary fractions, fixed-point and floating-point representation, arithmetic operations, two's complement, and floating-point numbers.
E N D
EEL 3705 / 3705LDigital Logic Design Fall 2006Instructor: Dr. Michael Frank Lecture Module #5:Radix Number Systems & Arithmetic M. Frank, EEL3705 Digital Logic, Fall 2006
Binary Fractions Fixed-Point and Floating-Point Binary Fractional Numbers M. Frank, EEL3705 Digital Logic, Fall 2006
Radix Fractions • In decimal, we write digits after the decimal point to denote coefficients of negative powers of 10. • Example: 3.14159 means: • 3×100 + 1×10−1 + 4×10−2 + 1×10−3 + 5×10−4 + 9×10−5 • By the same token, in any base b, digits after the “radix point” denote coefficients of negative powers of b. • General form: dk−1dk−2…d2d1d0.d−1d−2d−3…d−j+1d−j k digits beforethe radix point j digits afterthe radix point M. Frank, EEL3705 Digital Logic, Fall 2006
Fixed-Point Binary Fractions • In a fixed-width, fixed-point binary representation of a fractional number, the “binary point” is always implicitly at some predefined location (independent of the data) • E.g., suppose it is defined to be in between the first 5 and last 3 bits of an 8-bit word… • Then k=5, j=3… • The value of the bit pattern shown is then: • 8 + 2 + 1 + ½ + 1/8 = 11.62510 01 0 1 1 1 0 1 −1 −2 −3 4 3 2 1 0 M. Frank, EEL3705 Digital Logic, Fall 2006
Fixed-Point Binary Arithmetic 1011× 0101 10110000 1011 110111round to:11.102 = 3.510 • Analogous to arithmetic with ordinary decimal fractions. • Just like binary integer arithmetic, except that you must align the binary points, and ensure that the radix point of the result is positioned as expected, and round as needed. • Example: In k=2,j=2 fixed point, multiply 10.112× 1.012. Decimal equivalent:2.75× 1.253.4375round to nearest 0.25 3.5 M. Frank, EEL3705 Digital Logic, Fall 2006
Fixed-Point Two’s Complement • Can represent signed fractional numbers using fixed-point two’s complement representation. • Just as with integers, the bit in the most significant position (position k−1) represents the coefficient of the highest power of two, 2k−1, except that its value is negative. • Arithmetic procedures and overflow conditions are essentially the same as with integer two’s complement. M. Frank, EEL3705 Digital Logic, Fall 2006
Floating-Point Numbers • Similar to scientific notation, but not based on the radix 10… • The radix that is standardly used in digital floating-point representations is 2 • Advantages include: • Precisely handles a wider range of numeric magnitudes. • General mathematical form: ±N = ±M× rE • M, the mantissa, is a fixed-point number, usually normalized to [0,1). • r, the radix, is an implicitly agreed upon constant. • E, the exponent, is a signed integer (usu. in biased representation). • The fixed point number (dk−1…d0.d−1…d−j)rgets represented in normalized FP as (.dk−1…d0d−1…d−j)×rk. • Mantissa signs are usually represented in sign-magnitude form • The leading 1 of normalized binary mantissas can be left implicit M. Frank, EEL3705 Digital Logic, Fall 2006
Simple Floating-Point Example • Represent the number −3.2510 as a 10-bit floating-point binary number composed of a sign bit, a 4-bit exponent with a bias of 8, and a 5-bit mantissa with an implicit leading 1. • −3.2510 = −11.012 = −.1101×22 • Mantissa bits: 10100 (leading 1 is implicit) • Biased exponent = 2+8 = 1010 = 10102. • Complete representation: 11010101002 mantissa exp sign M. Frank, EEL3705 Digital Logic, Fall 2006