How to calculate range for 16-bit floating-point with 7-bit exponent and 9-bit mantissa?

160 Views Asked by At

Compare the range of representable numbers for 16-bit floating-point word with 7-bit exponent and 9-bit mantissa as (i) fraction and (ii) integer.

I know how to find range for a 16 bit integer but not sure how to find same for floating point and how it changes with exponent and mantissa. Kindly help to share detailed answer with some additional examples.

1

There are 1 best solutions below

0
ikegami On

A floating point number is typically stored as

+/- 1.________ x 2 ^ ( ______ - k )

The first blank being the mantissa (excluding the leading one), and the second blank being the exponent plus some constant k. One exponent value is usually reserved to indicate zero and subnormals, and another value is usually reserved for the NaNs and infinities.

The described format is weird since it doesn't have space for a sign bit.

⇒ Are we to assume it can only represent positive numbers?

The description of the format is lacking, missing any mention of k, and missing instructions on how to save zero, NaNs and infinities.

⇒ Are we to assume it can't represent zero?

⇒ Are we to assume k is zero, meaning it can't represent number smaller than 1? (For example, 0.1 would not be representable.)

If so, the smallest number representable is

       ____9____           ___7___
  +0b1.000000000 × 2 ^ ( 0b0000000 - 0 )
= +1 × 2 ^ 1
= +1 × 1
= +1

And the largest is

  +0b1.111111111 × 2 ^ ( 0b1111111 - 0 )
  +0b1111111111 × 2 ^ ( 0b1111111 - 0 - 9 )
= +1023 × 2 ^ ( 127 - 0 - 9 )
= +1023 × 2 ^ 118
= +1023 × 332306998946228968225951765070086144
= +339950059921992234495148655666698125312

But again, that's based on a lot of guesswork about the specifics for the format.