In C, nextdown() returns the next representable floating-point value after x in the direction of negative infinity. It steps one ulp downward on the number line.
You pass one double. The result is a double. Include <math.h>. nextdown is newer (C23). Older compilers and libraries may not provide it yet—check your toolchain before you rely on it.
Think of it as “go one tiny step down.” For many hosts, nextdown(x) matches the idea of nextafter(x, -INFINITY). Prefer the standard name when your library supports C23.
Syntax
Pass the floating-point value. Start with this call.
C
nextdown(1.0);
Call
What it does
nextdown(1.0);
Returns the next double strictly less than 1.0.
Include <math.h>. On GCC, link with -lm. Confirm C23 support; some platforms still lack nextdown.
Call nextdown in a small loop to move several ulps downward.
C
#include <stdio.h>
#include <math.h>
int main(void) {
double x = 0.0;
int i;
for (i = 0; i < 3; i++) {
x = nextdown(x);
printf("step %d: %.17g\n", i + 1, x);
}
return 0;
}