# Imaginary numbers and negative zero

I've been studying the low-level hardware implementations of floating point numbers and doing an exercise to design a custom floating point implementation.

I know that being able to represent negative zero is important for some purposes, but ran across a curious question.

Complex numbers are generally represented by two fp numbers. Is there any use in being able to represent negative zero on the imaginary line? Does anybody use this for anything?

Yes, there is a usage for the negative imaginary zero. But first, I will say something about the negative zero in general.

## Why have a negative zero?

First of all, the main reason to have a signed zero for floating points is that floating points have only limited precision and we often want to distinguish the following cases of a real number $x$, represented by a floating point:

• $x\geq 0$, which we will denote by $+0$.
• $x<0$, which we will denoted by $-0$.

As we cannot distinguish between these cases ordinarily in our floating point representation when $|x|$ is smaller than the floating point precision, we need a special notation for this. We want to distinguish between these two almost $0$ numbers, as this difference can be 'enlarged' with the appropriate function: when we have defined $1/0=\infty$ (we work with the extended reals) we have $+0={-0}$, but $1/{-0}={-\infty}\neq +\infty = 1/{+0}$.

## The negative imaginary zero

For the following, consider a complex number $z=x+i\cdot y$, with $x$ the real part and $y$ the imaginary part, represented by a floating point for $x$ and another floating point for $y$.

One important application where we want to distinguish between $-0$ and $+0$ is when computing the inverse elementary functions (i.e. $\ln(z), \sqrt{z}, \arcsin(z)$) for the complex numbers. All these functions are defined in terms of $\ln(z)$, the complex logarithm.

I won't go into the details why, but this function is discontinuous on the whole negative real number line: $\ln(x + i\cdot +0)\neq \ln(x+i\cdot{-0})$ for all $x\leq 0$, this is half-line known as the branch cut of the complex logarithm. (Note that we also want to know the sign of $x$ here to see whether are 'on' this line in the first place!)

For example, we have $-4+i0 = -4 - i0$, but $2i=\sqrt{-4+i0 }\neq \sqrt{-4-i0}=-2i$. So, we need to distinguishing between $+i0$ and $-i0$ to know on which 'side' of the branch cut we are to compute the complex logarithm $\ln(x)$ and all other inverses of elementary functions defined from it. For more on this topic, see these notes by Prof. W. Kahan.

• You had me at 1/−0 = −∞ ≠ ∞ = 1/0. Apr 25 '18 at 6:33