diff options
Diffstat (limited to 'src/math/lrint.c')
| -rw-r--r-- | src/math/lrint.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/math/lrint.c b/src/math/lrint.c index 16eaf7be..3ce1dd66 100644 --- a/src/math/lrint.c +++ b/src/math/lrint.c @@ -1,9 +1,23 @@ # define TGSOURCE "lrint.c" #include "_tgmath.h" #include <math.h> +#include "limits.h" +#include "fenv.h" long int TGFN(lrint)(TYPE x) { + switch (fpclassify(x)) { + case FP_ZERO: + return 0; + + case FP_INFINITE: + feraiseexcept(FE_INVALID); + return signbit(x) ? LONG_MIN : LONG_MAX; + + default: + break; + } + return x; } |
