FEGETROUND(3POSIX)

🌸 FEGETROUND(3POSIX) β€” the POSIX Programmer's Manual, bestie edition 🌸

okay so. this is from the POSIX Programmer's Manual, and before we even get into it, there's a lil disclaimer you gotta hear.

πŸŽ€ PROLOG πŸŽ€

so this page lives inside the POSIX Programmer's Manual, right? but the Linux implementation of this interface might be different β€” like, check the matching Linux manual page for the Linux tea. or honestly? it might not even be implemented on Linux at all. no cap. πŸ’€


✨ NAME ✨

fegetround, fesetround β€” get and set the current rounding direction 🧚


πŸ’– SYNOPSIS πŸ’–

#include <fenv.h>

int fegetround(void);
int fesetround(int round);

πŸ¦‹ DESCRIPTION πŸ¦‹

so first thing: everything described on this reference page is aligned with the ISO C standard. if anything here conflicts with the ISO C standard, that's unintentional, okay? not the vibe. this volume of POSIX.1‐2017 defers to the ISO C standard, periodt.

The fegetround() function shall get the current rounding direction. 🎯

The fesetround() function shall establish the rounding direction represented by its argument round. and listen β€” if that argument is not equal to the value of a rounding direction macro, then the rounding direction is not changed. it just sits there. unchanged. iconic behaviour honestly.


⭐ RETURN VALUE ⭐

fegetround() shall return the value of the rounding direction macro that represents the current rounding direction β€” or a negative value if there's no such rounding direction macro, or if the current rounding direction is just not determinable. 😭

fesetround() shall return a zero value if and only if the requested rounding direction was actually established. if and only if. that's the whole deal. πŸ’…


πŸ”₯ ERRORS πŸ”₯

No errors are defined.

and btw the following sections are informative β€” like, they're extra context, not the strict rules. πŸ™ˆ


🌈 EXAMPLES 🌈

here's a whole example that saves, sets, and restores the rounding direction β€” and if setting it fails, it reports an error and aborts. dramatic? maybe. correct? absolutely.

#include <fenv.h>
#include <assert.h>
void f(int round_dir)
{
    #pragma STDC FENV_ACCESS ON
    int save_round;
    int setround_ok;
    save_round = fegetround();
    setround_ok = fesetround(round_dir);
    assert(setround_ok == 0);
    /* ... */
    fesetround(save_round);
    /* ... */
}

πŸ‘‘ APPLICATION USAGE πŸ‘‘

None.


πŸ’œ RATIONALE πŸ’œ

None.


🫢 FUTURE DIRECTIONS 🫢

None.


πŸ“ SEE ALSO πŸ“

The Base Definitions volume of POSIX.1‐2017, <fenv.h>

iykyk β€” go read that header. πŸ“š


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 .


okay that's the whole page, no notes, you understood all of it, main character energy fr fr πŸ’…βœ¨

and that's a wrap bestie β€” this was IEEE/The Open Group, 2017, FEGETROUND(3POSIX). go forth and round responsibly πŸ¦‹πŸ’–