FEGETROUND(3P)

πŸ’– FEGETROUND πŸ’–

okay bestie, welcome to the POSIX Programmer's Manual β€” this is the fegetround, fesetround page and it's literally all about which way your floats round. pull up a chair, we're getting into it πŸŽ€

🌸 PROLOG 🌸

This manual page is part of the POSIX Programmer's Manual. Heads up though: the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for the details of Linux behavior, okay?), or the interface may not be implemented on Linux at all. πŸ™ˆ


✨ NAME ✨

fegetround, fesetround β€” get and set current rounding direction. yep that's the whole thing, that's the job. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <fenv.h>

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

look at that. two little functions. adorable. 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

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 conflict is unintentional β€” nobody did that on purpose. This volume of POSIX.1‐2017 defers to the ISO C standard. periodt.

The fegetround() function shall get the current rounding direction. it's giving "read the vibe of the current rounding."

The fesetround() function shall establish the rounding direction represented by its argument round. And important: if the argument is not equal to the value of a rounding direction macro, then the rounding direction is not changed β€” it just sits there, unbothered, unbothered by your nonsense argument. 😌

πŸ’€ RETURN VALUE πŸ’€

The fegetround() function shall return the value of the rounding direction macro representing the current rounding direction, or a negative value if there is no such rounding direction macro, or if the current rounding direction is not determinable. so like, negative value = "idk bestie, can't tell you."

The fesetround() function shall return a zero value if and only if the requested rounding direction was established. zero = slay, we did it. anything else = we did not do it.

πŸ“ ERRORS πŸ“

No errors are defined. none. zero. nothing. the error section is on a gap year. πŸ’…

The following sections are informative.

🌈 EXAMPLES 🌈

The following example saves, sets, and restores the rounding direction, reporting an error and aborting if setting the rounding direction fails. like a little save point, so cute:

#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);
    /* ... */
}

save the round, set the round, assert the round worked, do your little /* ... */ business, put the round back. main character energy fr fr. ✨

πŸŽ€ APPLICATION USAGE πŸŽ€

None. nothing to add. no notes. πŸ’–

🧚 RATIONALE 🧚

None. also nothing. we simply have no thoughts, head empty. πŸ¦‹

⭐ FUTURE DIRECTIONS ⭐

None. the future is bright and the future contains no new directions here. 🌸

πŸ’œ SEE ALSO πŸ’œ

  • The Base Definitions volume of POSIX.1‐2017, <fenv.h> β€” go read that one next, iykyk.

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 .


ngl, if you spot a typo in here, it's probably a conversion-era artifact, not the actual standard's fault. the referee document stays undefeated. πŸ‘‘

and that's the page!! this one came to you from IEEE/The Open Group, dated 2017, and it lives in section 3P of the POSIX Programmer's Manual. love that for us. bye bestie, go set your rounding direction responsibly πŸ’–πŸ’…πŸ«Ά

πŸ“¦ where this page comes from