目录 ← 首页
CS61C

Summary

And in Conclusion\dots

The IEEE 754 standard defines a binary representation for floating point values using three fields.

Reprint of the 32-bit IEEE 754 single-precision layout: sign bit, exponent field, and fraction bits ordered from most significant to least significant as in the floating-point representation section.

Single-Precision (32-bit) Floating Point Representation (reprint of #fig-float from this section). The leftmost bit is the most significant bit; the rightmost bit is the least significant bit.

  • The sign determines the sign of the number (00 for positive, 11 for negative).

  • The exponent is in biased notation. For single-precision floating point numbers, the bias is 127−127, which comes from (2(81)1)-(2^{(8−1)} −1). For double-precision floating point numbers, the bias is 1023−1023. An exponent of 00000000 represents a denormalized number and an exponent of 11111111 represents either NaN, if there is a non-zero mantissa, or infinity, if there is a zero mantissa.

  • The significand is used to store a fraction instead of an integer and refers to the bits to the right of the leading “1” when normalized. For example, if a mantissa is 1.010011, its significand is 010011.

  • For normalized floats:

Value=(1)Sign×2Exp+Bias×1.Significand2\text{Value} = (−1)^{\text{Sign}} × 2^{\text{Exp}+\text{Bias}} × 1.\text{Significand}_2

Value=(1)Sign×2Exp+Bias+1×0.Significand2\text{Value} = (−1)^{\text{Sign}} × 2^{\text{Exp}+\text{Bias}+1} × 0.\text{Significand}_2

When translating between binary and decimal floating point values, we must remember that there is a bias for the exponent.

Reprint of the table summarizing IEEE 754 single-precision exponent encodings for normalized, denormalized, infinity, and NaN cases from the special floating-point values section.

The IEEE 754 single-precision exponent field has values from 00 to $255 (reprint of #tab-float-exp-fields from this section).

Textbook Readings

P&H 3.5, 3.9

Additional References

Exercises

Check your knowledge!

Conceptual Review