REMQUO(3P)

✨ REMQUO(3P) β€” the POSIX girlie manual ✨

okay bestie, this one is remquo from the POSIX Programmer's Manual (that's the 3P in the name, iykyk) πŸ’–

🌸 PROLOG 🌸

so like, real talk first: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β€” like, actually consult the corresponding Linux manual page for the deets on Linux behavior β€” or honestly the interface might not even be implemented on Linux at all 😭. no cap.


πŸ’… NAME πŸ’…

remquo, remquof, remquol β€” the remainder functions. periodt.


πŸŽ€ SYNOPSIS πŸŽ€

#include <math.h>

double remquo(double x, double y, int *quo);
float remquof(float x, float y, int *quo);
long double remquol(long double x, long double y, int *quo);

three flavors, one vibe. 🌈


πŸ¦‹ DESCRIPTION πŸ¦‹

so the functionality described on this reference page is aligned with the ISO C standard. if there's any conflict between the requirements described here and the ISO C standard, that's unintentional β€” this volume of POSIX.1‐2017 defers to the ISO C standard, okay? it's not that deep, the standard wins. πŸ’œ

now the actual tea: remquo(), remquof(), and remquol() shall compute the same remainder as the remainder(), remainderf(), and remainderl() functions, respectively. same energy, different name bestie.

and then β€” the main character move β€” in the object pointed to by quo, they store a value whose sign is the sign of x/y and whose magnitude is congruent modulo 2n to the magnitude of the integral quotient of x/y, where n is an implementation-defined integer greater than or equal to 3. iconic behavior honestly.

⚠️ but bestie, if y is zero, the value stored in the object pointed to by quo is unspecified. like, we don't know her. don't count on it. πŸ’€

and if you're the type of application that wants to check for error situations (responsible queen behavior 🫢), you should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. then on return, if errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. that's your vibe check. ⭐


🌟 RETURN VALUE 🌟

these functions shall return x REM y. simple as that, bestie.

on systems that do not support the IEC 60559 Floating-Point option, if y is zero, it is implementation-defined whether a domain error occurs or zero is returned. so like, depends on the system, lowkey unpredictable. πŸ™ˆ

if x or y is NaN, a NaN shall be returned. NaN in, NaN out, that's the law. ✨

if x is ±Inf or y is zero and the other argument is non-NaN, a domain error shall occur, and a NaN shall be returned. so like, that's a real error moment, not a fake one. 😭


πŸ”₯ ERRORS πŸ”₯

these functions shall fail if:

  • Domain Error β€” the x argument is Β±Inf, or the y argument is Β±0 and the other argument is non-NaN.
    • if the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [EDOM].
    • if the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid floating-point exception shall be raised.

these functions may fail if:

  • Domain Error β€” the y argument is zero.
    • if the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [EDOM].
    • if the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid floating-point exception shall be raised.

and then β€” plot twist β€” the following sections are informative. so like, the rest is bonus content, not requirements. πŸ’…


🌈 EXAMPLES 🌈

None.

literally nothing. not one example. we move. 😭


πŸ“ APPLICATION USAGE πŸ“

on error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. they're not besties, they don't depend on each other, but you need at least one of them showing up to the function. ✨


πŸ’œ RATIONALE πŸ’œ

so these functions are intended for implementing argument reductions which can exploit a few low-order bits of the quotient. that's the whole point of the quo situation β€” you don't need the whole quotient, just the vibe of a few low bits. πŸŽ€

and note: x may be so large in magnitude relative to y that an exact representation of the quotient is not practical. like, the quotient is simply too big to hold, bestie. that's why this function exists. πŸ‘‘


🧚 FUTURE DIRECTIONS 🧚

None.

the future is bright and empty. slay. 🌟


πŸ‘‘ SEE ALSO πŸ‘‘

  • feclearexcept()
  • fetestexcept()
  • remainder()

and also, from 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. so like, if there's drama, the original wins, no debate. πŸ’…

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 . we appreciate you fr fr πŸ™


okay that's the whole page bestie, hope you ate it up πŸ’– this was brought to you by IEEE/The Open Group, 2017, and it's giving REMQUO(3P) energy all the way to the end. mwah! πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from