CEIL(3POSIX)

πŸ’« PROLOG πŸ’«

ok bestie so before we even get into it β€” this manual page is part of the POSIX Programmer's Manual. That's the vibe. But heads up: the Linux implementation of this interface may differ (so like, go consult the corresponding Linux manual page for the deets on Linux behavior), or the interface might just... not be implemented on Linux at all. πŸ™ˆ Either way, we proceed.


✨ NAME ✨

ceil, ceilf, ceill β€” the ceiling value function. it's giving "round up but make it math" πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <math.h>

double ceil(double x);
float ceilf(float x);
long double ceill(long double x);

🌸 DESCRIPTION 🌸

ok so the functionality described on this reference page is aligned with the ISO C standard. If there's any conflict between what's described here and the ISO C standard β€” that's unintentional, no cap, nobody meant that. This volume of POSIX.1‐2017 defers to the ISO C standard. periodt.

These functions shall compute the smallest integral value not less than x. Like, the tiniest whole number that's still β‰₯ x. You're never going below x, you're going up to the next integer (or staying put if x is already an integer). πŸ‘‘


πŸ’– RETURN VALUE πŸ’–

The result shall have the same sign as x. yes literally, sign stays.

Upon successful completion, ceil(), ceilf(), and ceill() shall return the smallest integral value not less than x, expressed as a type double, float, or long double, respectively. (matching energy, matching types 🫢)

If x is NaN, a NaN shall be returned. it's giving NaN in, NaN out.

If x is Β±0 or Β±Inf, x shall be returned. unchanged. iconic behavior honestly.


πŸ’€ ERRORS πŸ’€

No errors are defined. not a single one. flawless. ✨

The following sections are informative.


πŸ¦‹ EXAMPLES πŸ¦‹

None. 😭 that's it, that's the section, nothing to see here bestie.


🌈 APPLICATION USAGE 🌈

ok this part matters, listen up:

  • The integral value returned by these functions need not be expressible as an intmax_t. so like, don't just assume it'll fit. 🚨
  • The return value should be tested before assigning it to an integer type, to avoid the undefined results of an integer overflow. yes, undefined results β€” we do NOT want that.

Also: these functions may raise the inexact floating-point exception if the result differs in value from the argument. sneaky but true.


🧚 RATIONALE 🧚

None. πŸ’œ


⭐ FUTURE DIRECTIONS ⭐

None. the future is bright and also empty.


πŸ‘‘ SEE ALSO πŸ‘‘

  • feclearexcept()
  • fetestexcept()
  • floor()
  • isnan()

The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, <math.h>


Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page bestie πŸ’… courtesy of IEEE/The Open Group, dated 2017 β€” she's a classic, she's CEIL(3POSIX), and she ate. mwah 🫢✨