summaryrefslogtreecommitdiff
path: root/src/math/llrint.c
blob: 9ec492d462b062e34c47c454cc0bb70f8f64d949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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;
}

/*
STDC(199901)
LINK(m)
*/