# Relative distance between two floating-point numbers

Let $\mathbb G(q,l)$ to be the set of all floating-point numbers in the base $q$ and with a mantissa of a length $l$. In the lecture notes I am trying to learn from, the following is said to be obvious (and consequently has no proof):

$$\forall x \in \mathbb G(q,l), \forall y \in \mathbb G(q,l)\setminus\{x\}: |x-y| \ge |x|q^{-l}$$

What I have tried so far:

Let $x=(-1)^m a \cdot q^\alpha$ and $y=(-1)^n b \cdot q^\beta \in \mathbb G(q,l)$ such that $x \ne y$, then

\begin{align} |x-y| &\ge |x|-|y| \\ &=|(-1)^m a \cdot q^\alpha|-|(-1)^n b \cdot q^\beta| \\ &=a \cdot q^\alpha - b \cdot q^\beta \\ &\ge ...? \end{align}

• It's certainly not true if $y=x$. Presumably they mean $y \ne x$. – Robert Israel Dec 24 '12 at 0:24
• The first line $|x-y|\geq |x|+|y|$ is incorrect. The inequality goes the other way. – Alex Becker Dec 24 '12 at 0:30
• Thank you, Robert and Alex, I've fixed the above-mentioned. – Leo Dec 24 '12 at 0:35

Since it's true for $x=0$, we may assume $x \ne 0$. By symmetry, assume $x > 0$. Let $x = a \cdot q^\beta$ with $a$ an integer, $q^{\ell-1} \le a \le q^{\ell} - 1$. Let $y_1$ and $y_2$ be the greatest floating-point number $< x$ and the least floating-point number $>x$ respectively. If $q^{\ell-1} < a$, then $y_1 = (a-1) \cdot q^\beta$ and $|x - y_1| = q^\beta$ while $x q^{-\ell} = a \cdot q^{\beta - \ell} < q^{\beta}$. Similarly, if $a < q^{\ell}-1$, $|x - y_2| = q^\beta$. I'll leave it to you to try $|x - y_1|$ with $a = q^{\ell-1}$ and $|x - y_2|$ with $a = q^{\ell}-1$.