Numworks Epsilon  1.4.1
Graphing Calculator Operating System
nearbyintf.c
Go to the documentation of this file.
1 #include <math.h>
2 
3 #undef nearbyintf
4 
5 /* nearbyintf is not supposed to be the same as roundf according to OpenBSD's
6  * documentation. Indeed:
7  * - they round halfway cases to the nearest integer instead of away from zero
8  * (nearbyint(4.5) = 4 while round(4.5) = 5 for example).
9  * - nearbyint is guaranteed never to set floating point flags or trigger
10  * floating point exceptions (which are disabled by default)
11  * accroding to OpenBSD open manual page.
12  *
13  * However, as nearbyintf is required by micropython only, in order to save
14  * space and time (nearbyintf OpenBSD 6.0 implementation required some other
15  * function implementation), we used roundf. */
16 
17 float nearbyintf(float x) {
18  return roundf(x);
19 }
#define roundf(x)
Definition: math.h:154
float nearbyintf(float x)
Definition: nearbyintf.c:17