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