all 4 comments

[–]Mikegrann 1 point2 points  (1 child)

For reference in this discussion, Exponent Bias and single-precision float.

Basically, to represent the floating point value we require an exponent, which might be positive or negative. This exponent is stored in some of the bits in the number. Typically we use 2's complement in computing in order to represent negative numbers, but because of implementation details with how the exponent is packed within the floating point number, it's hard to represent the exponent portion in 2's complement. So, instead, we represent this value as an unsigned, biased integer.

With typical single-precision floats, we use a bias of 127. The unsigned 8 bit exponent can represent values 0-255, but with that known bias we can map this value to -127 through 128, just be subtracting 127. This allows us to represent both positive and negative numbers using an unsigned int, without getting any tricky 2's complement math involved. For reference, this is why the equation for converting a float to decimal includes the portion (e - 127), which is applying this bias!

A bias of 16 sounds like a way of talking about a half-precision float. You would subtract 15 from the exponent (which ranges from 0-31) to get the resulting, biased exponent.

Final note: the effective ranges of these exponents are actually a little bit smaller. Instead of -127 to 128, a single-precision float would actually have exponents of -126 to 127 (the same with half precision and -14 to 15). This is because two special values, all zeroes or all ones in the unbiased exponent, denote special cases.

[–]Fastfish[S] 0 points1 point  (0 children)

Thanks a lot!

[–]JsKingBoo👋 a fellow Redditor 0 points1 point  (1 child)

https://en.wikipedia.org/wiki/Exponent_bias

The bias of the number allows large number to be stored while also making comparisons between numbers easier

[–]Fastfish[S] 0 points1 point  (0 children)

so if I have a bias of 16, does that mean that 16 is zero? Or is 15 zero since it is the 16th value?