DougEC
DougEC

Reputation: 355

How to represent -0 in binary

This question concerns converting a floating point number that is less than abs(1) and negative to 32.32 format, for example: -0.1234.

When this is converted to 32.32, the integer portion and fractional portion are separated into the upper and lower 32 bit words, respectively. In this example above, the upper 32-bits will hold -0, while the lower will hold .1234, both converted to binary.

So the question is, in this case, how does one properly represent the -0 value in binary?

Upvotes: 0

Views: 2406

Answers (2)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272717

It depends.

Upvotes: 3

zellio
zellio

Reputation: 32524

+0 == 0 == -0 for practical purposes of programming. In this case, you would have to figure out how negative numbers are being handled but the underlying system. ( Generally either two's complement or sign bit ) and monkey with that accordingly.

Upvotes: 0

Related Questions