notes:ieee_754-1985

This shows you the differences between two versions of the page.

Both sides previous revision Previous revision | Next revision Both sides next revision | ||

notes:ieee_754-1985 [2013/02/24 00:09] andy [IEEE 754-1985] |
notes:ieee_754-1985 [2013/02/24 00:11] andy [Normalised Values] |
||
---|---|---|---|

Line 45: | Line 45: | ||

The most common form of IEEE floating point numbers is the normalised form --- this is where the exponent has a value in the valid range (once the bias has been subtracted from the unsigned value stored). As explained above, the significand stores only the digits after the leading **1**, which is implicit. | The most common form of IEEE floating point numbers is the normalised form --- this is where the exponent has a value in the valid range (once the bias has been subtracted from the unsigned value stored). As explained above, the significand stores only the digits after the leading **1**, which is implicit. | ||

- | If the standard C library is available, the ''[[man>frexp|frexp()]]'' function normalises a floating point value such that the fractional part will be in the range **0.5 ≤ x < 1.0**. Multiplying this value by **2** and reducing the exponent by **1** yields a value in the desired range **1.0 ≤ x < 2.0**. At this point the leading digit can then be discarded as the implicit leading **1** (see the [[#Significand]] section for details). | + | If the standard C library is available, the ''[[man>frexp|frexp()]]'' function normalises a floating point value such that the fractional part will be in the range $0.5 \le \times < 1.0$. Multiplying this value by **2** and reducing the exponent by **1** yields a value in the desired range $1.0 \le \times < 2.0$. At this point the leading digit can then be discarded as the implicit leading **1** (see the [[#Significand]] section for details). |

If ''frexp()'' is available then it should be used, as it will likely use the underlying hardware representation to avoid expensive loops. However, a naive implementation can quite simply mimic its functionality --- the following version demonstrates the principle, but a production version would also need to check for special values (zero, NaN, infinities) as well as catching under- and overflows: | If ''frexp()'' is available then it should be used, as it will likely use the underlying hardware representation to avoid expensive loops. However, a naive implementation can quite simply mimic its functionality --- the following version demonstrates the principle, but a production version would also need to check for special values (zero, NaN, infinities) as well as catching under- and overflows: |

notes/ieee_754-1985.txt · Last modified: 2013/02/24 00:18 by andy