1lrint(3M) Mathematical Library Functions lrint(3M)
2
3
4
6 lrint, lrintf, lrintl - round to nearest integer value using current
7 rounding direction
8
10 c99 [ flag... ] file... -lm [ library... ]
11 #include <math.h>
12
13 long lrint(double x);
14
15
16 long lrintf(float x);
17
18
19 long lrintl(long double x);
20
21
23 These functions round their argument to the nearest integer value,
24 rounding according to the current rounding direction.
25
27 Upon successful completion, these functions return the rounded integer
28 value.
29
30
31 If x is NaN, a domain error occurs and an unspecified value is
32 returned.
33
34
35 If x is +Inf, a domain error occurs and an unspecified value is
36 returned.
37
38
39 If x is −Inf, a domain error occurs and an unspecified value is
40 returned.
41
42
43 If the correct value is positive and too large to represent as a long,
44 a domain error occurs and an unspecified value is returned.
45
46
47 If the correct value is negative and too large to represent as a long,
48 a domain error occurs and an unspecified value is returned.
49
51 These functions will fail if:
52
53 Domain Error The x argument is NaN or ±Inf, or the correct value is
54 not representable as an integer.
55
56 If the integer expression (math_errhandling &
57 MATH_ERREXCEPT) is non-zero, then the invalid floating-
58 point exception is raised.
59
60
62 An application wanting to check for exceptions should call feclearex‐
63 cept(FE_ALL_EXCEPT) before calling these functions. On return, if
64 fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is
65 non-zero, an exception has been raised. An application should either
66 examine the return value or check the floating point exception flags to
67 detect exceptions.
68
70 See attributes(5) for descriptions of the following attributes:
71
72
73
74
75 ┌─────────────────────────────┬─────────────────────────────┐
76 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
77 ├─────────────────────────────┼─────────────────────────────┤
78 │Interface Stability │Standard │
79 ├─────────────────────────────┼─────────────────────────────┤
80 │MT-Level │MT-Safe │
81 └─────────────────────────────┴─────────────────────────────┘
82
84 feclearexcept(3M), fetestexcept(3M), llrint(3M), math.h(3HEAD),
85 attributes(5), standards(5)
86
87
88
89SunOS 5.11 12 Jul 2006 lrint(3M)