What is a “bias value” of floating-point numbers?

后端 未结 4 1711
再見小時候
再見小時候 2020-12-22 17:00

In learning how floating point numbers are represented in computers I have come across the term \"bias value\" that I do not quite understand.

The bias value in floa

4条回答
  •  忘掉有多难
    2020-12-22 17:20

    Adding more detail to above answers.

    To represent 0, infinity and NaN (Not-a-Number) in floating point, IEEE decided to use special encoding values.

    • If all bits of the exponent field are set to 0, then the floating-point number is 0.0.

    • If all bits of the exponent field are set to 1 and all bits of the fraction part are 0, then the floating-point number is infinity.

    • If all bits of the exponent field are set to 1 and all bits of the fraction part are not equal to 0, then the floating point number is NaN.

    So, in single-precision we have 8 bits to represent the exponent field and there are 2 special values, so we basically have 256 - 2 = 254 values that can be represented in exponent. So, we can effectively represent -126 to 127 in the exponent, i.e., 254 values (126 + 127 + 1), 1 is added for 0.

提交回复
热议问题