Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001
Representations of numbers Unsigned integers Signed integers Fixed-point numbers Floating-point numbers
Base-10 (decimal) arithmetic Uses the ten numbers from 0 to 9 Each column represents a power of 10
Base-10 (decimal) arithmetic Uses the ten numbers from 0 to 9 Each column represents a power of 10
Standard binary representation Uses the two numbers from 0 to 1 Every column represents a power of 2
Fixed-point representation Uses the two numbers from 0 to 1 Every column represents a power of 2
Addition Base-10Base-2
Conversion to base 10
Questions about binary data Is it signed or unsigned? What exponent is used for each place?
Range of values in a byte
Scientific notation (1) One billion =1,000,000,000 =1 x 10 9 –significand or mantissa: 1 –base or radix: 10 –exponent: 9
Scientific notation (2) 1999 =1.999 x 10 3 –significand or mantissa: 1999 –base or radix: 10 –exponent: 3 =19.99 x 10 =199.9 x 10
Practice (base 10)
Base-2 scientific notation 2.25 ten =10.01 two =10.01 two x 2 0 =1.001 two x 2 1 normalized
8-bit floating point format (1) Note: This isn’t a standard format. It’s just for teaching purposes.
Improvements Bias the exponent –Always subtract a fixed amount, e.g., 3 –Allows representation of negative exponents Implicit one –What’s the Mills phone number? –Why use a bit for the leading one?
8-bit floating-point format (2) Exponent (3 bits) is biased by 3 The leading one of significand is implicit Zero is represented by all zeros
IEEE standard floating-point Single precision –32 bits sign: 1 bit exponent: 8 bits significand: 23 bits –Bias: 127 Double precision –64 bits sign: 1 bit exponent: 11 bits significand: 52 bits –Bias: 511
Practice 13 ten 1.25 ten 257 ten