1
$\begingroup$

There's a floating point question that popped up and I'm confused about the solution. It states that

IEEE 754-2008 introduces half precision, which is a binary floating-point representation that uses 16 bits: 1 sign bit, 5 exponent bits (with a bias of 15) and 10 significand bits. This format uses the same rules for special numbers that IEEE754 uses. Considering this half-precision floating point format, answer the following questions: ....

What is the smallest positive non-zero number it can represent?

The answer says: bias = 15 Binary representation is: $0 \, 00000 \, 0000000001 = 2^{-14} * 2^{-10}=2^{-24}$

I've understood the binary representation part, but how does it get to those exponents of 2??

$\endgroup$
1
$\begingroup$

In this example, $2^{-10}$ is the mantissa, and $2^{-14}$ is the exponent.

For a fuller explanation of subnormal numbers in IEEE-754 floating point, see this previous answer.

Your example binary16 (i.e. half-precision) floating point number is a subnormal number because the exponent field is the "all zeroes" pattern. This means:

  • The significand field contains the fractional part of the mantissa, with an implicit "0" to the left of the binary point.
  • The exponent is set to $2^{-14}$. For binary32 (i.e. single precision) this would be $2^{-126}$ and for binary64 (i.e. double precision) it would be $2^{-1022}$.

So the number is $+0.0000000001_2 \times 2^{-14} = 2^{-24}$.

$\endgroup$
4
  • $\begingroup$ ohh got it. tbh the next question doesn't really make sense either. It's "What is the largest non-infinite number it can represent". The binary representation is 0 11110 1111111111. They got 2^{16}-2^{5}. Where did the minus come from? $\endgroup$
    – Manny
    May 10 at 4:47
  • $\begingroup$ Well that answer is technically correct, but expressing it with a subtraction doesn't seem that helpful to me. It's better to think of it as $1.1111111111_2 \times 2^{15} = 65504$. $\endgroup$
    – Pseudonym
    May 10 at 4:51
  • $\begingroup$ Oh okay, got it! So you take the exponent bits, find out it's 30. You subtract 30-bias to get 15. But where do you get 1.111.... from? $\endgroup$
    – Manny
    May 10 at 21:31
  • $\begingroup$ @Manny The mantissa, 1.111..., is the significand field with "1." attached to the start. The implicit digit to the left of the binary point here is 1 because it is a normal number. $\endgroup$
    – Pseudonym
    May 11 at 4:49
0
$\begingroup$

Three simple steps:

  1. Write down how the number 1.0 is represented.

  2. Write down how the smallest normalised number is represented, and find its value.

  3. Find out how denormalised numbers are represented, and find the representation and value of the smallest denormalised number.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.