0
$\begingroup$

I'm studying floating point arithmetic and understand everything in the positive domain but can't seem to wrap my head around how negative floating point numbers are dealt with.

I understand that the sign bit in the 754 IEEE floating point number is the MSB of the bit representation of the number but how will a negative operand interact in terms of subtraction and in multiplication/division?

I apologize in advance if this is a trivial question or if there are resources online for this but I haven't been able to find anything that explains dealing with negative operands in a comprehensive manner.

Thank you.

$\endgroup$
0
$\begingroup$

Floating-point numbers on computers are problematic only because of the effects of their limited numbers of binary digits of precision and the limited range of exponents, leading to roundoff errors, underflow, overflow, and other such problems.

All of these problems occur when you are just using positive numbers with the operations of addition, subtraction, multiplication, and division.

In general, however, changing the sign of one of the operands in an operation on floating-point numbers has exactly the effect that it logically should have. Adding $-x$ to another number is exactly the same as subtracting $x.$ Subtracting $-x$ is exactly the same as adding $x.$ Multiplying $-x$ by $-y$ will give the same result as multiplying $x$ and $y.$ (It is possible that both results will be an overflow, but that's not a problem caused by the sign bit!)

One odd thing about negative floating-point numbers is that it's possible (at least in principle) to have a representation of negative zero that's distinct from positive zero. But I believe you have to get into some kind of exceptional case (underflow, operations with infinities, or the like) in order for this to be an issue.

If you can actually get your hands on one of the official IEEE specifications for floating-point arithmetic, I believe you will find everything there is to say about negative numbers spelled out in excruciatingly boring detail.

$\endgroup$
  • $\begingroup$ Thank you I will look it up. In the mean time, I get what you're saying about adding -x instead of subtracting x. How would I complement the floating point number? Would the manitssa be able to be "2's complemented"? $\endgroup$ – Philip Kwak Dec 7 '18 at 3:57
  • $\begingroup$ You don't "2s complement" a floating-point number. To change $x$ to $-x$ you just change the sign bit, and the mantissa and exponent stay the same. $\endgroup$ – David K Dec 7 '18 at 13:58

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.