nextup(3)
π nextup(3) β the bestie manual π
okay so bestie, welcome to nextup(3) from the Library Functions Manual π this is your girl explaining how to grab the very next floating-point number in whichever direction you want. no cap, these six functions are lowkey iconic.
β¨ NAME β¨
nextup, nextupf, nextupl, nextdown, nextdownf, nextdownl β return next floating-point number toward positive/negative infinity
like, they literally just scootch you one representable float over. one tiny step. that's it. that's the whole job. π
π LIBRARY π
Math library (libm, -lm)
so when you compile, don't forget the -lm at the end or the linker is gonna ghost you fr fr π
πΈ SYNOPSIS πΈ
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <math.h>
double nextup(double x);
float nextupf(float x);
long double nextupl(long double x);
double nextdown(double x);
float nextdownf(float x);
long double nextdownl(long double x);
six functions, one vibe check: three go up, three go down, and they come in double, float, and long double flavors π also head's up, you need that _GNU_SOURCE define, and you gotta check out feature_test_macros(7) about it β
π¦ DESCRIPTION π¦
nextup(), nextupf(), and nextupl() return the next representable floating-point number greater than x.
translation: the tiniest possible step to the right. like the very next door neighbor float. no stairs skipped, no cap. πͺ
If x is the smallest representable negative number in the corresponding type, these functions return -0. If x is +0 or -0, the returned value is the smallest representable positive number of the corresponding type.
(yes bestie, they really do hand you a -0 in that one specific case, that's not a typo, that's the standard being extra π)
If x is positive infinity, the returned value is positive infinity. If x is negative infinity, the returned value is the largest representable finite negative number of the corresponding type.
so +β just stays +β like it's too famous to move β¨ but ββ actually takes a step and lands on the biggest finite negative number. main character energy honestly π
If x is NaN, the returned value is NaN.
The value returned by nextdown(x) is -nextup(-x), and similarly for the other types.
obsessed with this btw β nextdown is literally just nextup in a mirror πͺ that's the whole trick, that's the tea, iykyk π
π« RETURN VALUE π«
See DESCRIPTION.
bestie the manpage really said "go reread the section above" and honestly? valid. it's all up there fr fr π«Ά
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
nextup(),nextupf(),nextupl(),nextdown(),nextdownf(),nextdownl()- Attribute: Thread safety
- Value:
MT-Safe
MT-Safe means these are safe to call from multiple threads at the same time, no drama, no fighting, they all get along π slay
β STANDARDS β
These functions are described in IEEE Std 754-2008 - Standard for Floating-Point Arithmetic and ISO/IEC TS 18661.
yes she's certified. standards-approved. a whole legitimate baddie of a function π
π HISTORY π
glibc 2.24.
(she's not ancient, but she's been around long enough to know things π)
π SEE ALSO π
if you likednextup, you're gonna wanna meet her cousins.nextafter(3)is the one who lets you pick the direction, andnearbyint(3)rounds like a pro π―
okay that's the whole page bestie, you're gonna do amazing, go forth and increment some floats πβ¨π
this gem came from Linux man-pages 6.20, dated 2026-02-08 β mwah, take care of her π«Άπ
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2016, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms