Consider the following $32$-bit floating-point representation scheme as shown in the format below :

A $1$ bit sign field

A $24$ bit fraction field

and a $7$ bit exponent field (in excess-$64$ signed integer representation, with 16 being the base of exponentiation)

How to represent the decimal value $-7.5$ as a normalized floating point number in the given format?

I am not getting why this question assumes $16$ being the base of exponentiation, as I have always assumed base $2$?

  • 1
    $\begingroup$ "I am not getting why is this question assumes 16…" You're not being asked about IEEE single precision anyway, since that uses 23 explicit bits for the fraction field. There is therefore no need to assume that the rest of this specification follows the IEEE rules :) $\endgroup$ – Patrick Stevens Dec 31 '16 at 9:32
  • $\begingroup$ @PatrickStevens Can you please Answer this. $\endgroup$ – Jon Garrick Dec 31 '16 at 10:28

I believe your question is:

I am not getting why is this question assumes $16$ being the base of exponentiation as I have always did by assuming base $2$?

Presumably it's as an exercise to see if you understand the principles behind floating point numbers rather than having just learnt a set of steps. The task is asking about a format which differs from IEEE single precision in two ways:

  • The exponent is in base 16 (rather than IEEE's 2);
  • the fraction field is 24 bits long (rather than IEEE's explicit 23 with an implied first bit being 1).

Since the question is not using a standard floating-point format anyway (because of point 2), why assume it would be standard in respect of point 1?

  • $\begingroup$ Yes, I looked at IEEE 754 representation which assumes base 2 and not 16 or any other bases. 1 is hidden bit in IEEE 754 . Have I got the understanding right ? $\endgroup$ – Jon Garrick Dec 31 '16 at 13:37
  • 1
    $\begingroup$ Yes, that's correct. $\endgroup$ – Patrick Stevens Dec 31 '16 at 14:43

As @PatrickStevens points out, this problem is meant to make you think about the basic ideas involved in floating point representation and explore some of the design trade-offs.

To find the representation of $-7.5$ in IEEE 754 single-precision format, you'd write it as $(-1)^1 \cdot 1.875 \cdot 2^{129-127}$.

The exponent $1$ is the sign bit, $1.875$ is a number in the required $1.f$ form, and $129$ is the excess-$127$ exponent. You'd then take $0.875$ and turn it into a $23$-bit binary number, convert $129$ to an $8$-bit binary number and put everything together to form a $32$-bit floating point number.

For your problem the steps are similar, obviously with a different base ($16$) and bias ($64$) for the exponent. The one interesting question you want to ask yourself before you get into the details is, can I still use the hidden-bit trick? That is, can I always write my number as $(-1)^s \cdot 1.f \cdot 16^\text{some integer}$?


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.