1
$\begingroup$

So I understand the logic behind converting positive decimal numbers to IEEE 32 bit floating numbers but I'm not completely sure behind the negative one's. If for example we have a decimal number say -15.5, do we have to do two's complement first then convert it to the floating point representation or we directly do it for 15.5 and at the sign bit we do 1. Thank you in advance.

$\endgroup$
1
  • $\begingroup$ What is a decimal number? I have intuitions about number, decimal representation of a number, and "IEEE format" number representations that work for me. $\endgroup$ – greybeard Apr 1 at 17:41
1
$\begingroup$

Contrary to two's complement representation of negative integers, the negative numbers in IEEE floating-point are represented with only a sign bit change, as shown in there.

For example, $0\cdot01111100\cdot01000000000000000000000$ is the representation of $0.15625$, and $1\cdot01111100\cdot01000000000000000000000$ is the representation of $-0.15625$.

In particular, there are two representations of zero (the positive one and the negative one).

$\endgroup$
0
$\begingroup$

IEEE floating point numbers have a sign bit. The representation of $-x$ is generally the same as that of $x$, with the sign bit flipped. This has the unfortunate consequence of having two different zeroes.

$\endgroup$
0
$\begingroup$

To get the binary representation for -x in IEEE754 floating point format, you start with the binary representation of x, then change the sign bit. That’s it.

$\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.