Let $F$ the set of all floating point number $n2^e$ such that $ -2^{53} < n < 2^{53}$ and $−1074 \leq e \leq 970$. Let $F^* = F - \{\max(F)\}$

I assume $F$ not to be dense, and therefore there must be a function $succ \left| \begin{array}{ll} F^*&\rightarrow F \\ f&\mapsto \min \{ g \in F, g>f\} \end{array} \right.$ to find "the very next" floating point number.

How does one compute $succ(f)$ ?

  • $\begingroup$ this seems to be nearly the ieee double precision binary format. if packed into a uint64_t with 1 sign bit, 11 exponent bits, 52 mantissa bits, then for finite positive normalized numbers (with leading 1 mantissa bit implicit), I think you can just add 1 to the uint64_t - if the mantissa doesn't overflow, it's fine, if the mantissa overflows from (1).111.. to (10).000..., the overflow goes into the exponent and increases it by 1, also fine. the corresponding C library function for this operation is called nextafter() (alternatively nexttoward()) $\endgroup$
    – Claude
    Oct 16, 2023 at 17:41
  • $\begingroup$ @Claude Thank you for your interest in the question, I appreciate the help. You are right, this is supposedly the ieee 64 but floating point number definition more or less. Can you demonstrate that incrementing the exponent must give the smallest increase in the floating point space ? Indeed, why couldn't there be another number in F with a smaller $n$ and larger $e$ that could squeeze between $f$ and your answer (and vice versa)? $\endgroup$
    – NRagot
    Oct 16, 2023 at 17:53
  • $\begingroup$ IEEE double normalized values have (implicit) leading 1 bit, so the fractional mantissa $m$ can be considered to be in $ 1 \le |m| < 2$. Denormalized values are smaller than the smallest normal number. Thus each number has a unique representation. $\endgroup$
    – Claude
    Oct 28, 2023 at 16:04
  • $\begingroup$ Your definition is not quite the same as IEEE double as $2n\times 2^{e-1}=n\times 2^e$ so representation is not unique, even if the set of representable values might be the same (I have not checked). $\endgroup$
    – Claude
    Oct 28, 2023 at 16:10

1 Answer 1


During the following, we will need to store values in the range $-2^{54}+2,\ldots, 2^{54}-1$ in $n$ and values from the range $-1127,\ldots ,970$ in $e$.

  • First handle special cases involving zero as input or output:
  1. If $n=0$, return $1\cdot 2^{-1074}$
  2. If $n=-1$ and $e=-1074$, return any representation of $0$ (e.g., $0\cdot 2^{42}$)
  • Now normalize to a definitely too long mantissa
  1. While $|n|<2^{53}$, set $n\leftarrow 2n$ and $e\leftarrow e-1$.
  • Advance to something definitely bigger (though not representable)
  1. Set $n\leftarrow n+1$
  • Work towards valid representations without making the value smaller
  1. While $|n|\ge 2^{53}$ or $e<-1074$, set $n\leftarrow \lfloor \frac {n+1}2\rfloor$ and $e\leftarrow e+1$
  • $\begingroup$ Thank you for your interest in the question, a few points. 1) is it original work ? if so, could you demonstrate its validity ? otherwise, could you refer to established work that use this method ? 2) would you mind expanding on the comment : "though not representable" ? I'm just a bit confused. I appreciate the help a lot $\endgroup$
    – NRagot
    Oct 16, 2023 at 17:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .