1LRINT(3P)                  POSIX Programmer's Manual                 LRINT(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       lrint, lrintf, lrintl — round to nearest integer  value  using  current
13       rounding direction
14

SYNOPSIS

16       #include <math.h>
17
18       long lrint(double x);
19       long lrintf(float x);
20       long lrintl(long double x);
21

DESCRIPTION

23       The  functionality described on this reference page is aligned with the
24       ISO C standard. Any conflict between the  requirements  described  here
25       and  the  ISO C  standard is unintentional. This volume of POSIX.1‐2017
26       defers to the ISO C standard.
27
28       These functions shall round  their  argument  to  the  nearest  integer
29       value, rounding according to the current rounding direction.
30
31       An  application  wishing to check for error situations should set errno
32       to zero and  call  feclearexcept(FE_ALL_EXCEPT)  before  calling  these
33       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
34       FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero,  an  error  has
35       occurred.
36

RETURN VALUE

38       Upon  successful  completion,  these functions shall return the rounded
39       integer value.
40
41       If x is NaN, a domain error shall occur and  an  unspecified  value  is
42       returned.
43
44       If  x  is  +Inf, a domain error shall occur and an unspecified value is
45       returned.
46
47       If x is -Inf, a domain error shall occur and an  unspecified  value  is
48       returned.
49
50       If  the correct value is positive and too large to represent as a long,
51       an unspecified value shall be returned.  On systems  that  support  the
52       IEC 60559 Floating-Point option, a domain error shall occur; otherwise,
53       a domain error may occur.
54
55       If the correct value is negative and too large to represent as a  long,
56       an  unspecified  value  shall be returned.  On systems that support the
57       IEC 60559 Floating-Point option, a domain error shall occur; otherwise,
58       a domain error may occur.
59

ERRORS

61       These functions shall fail if:
62
63       Domain Error
64                   The  x argument is NaN or ±Inf, or the correct value is not
65                   representable as an integer.
66
67                   If the integer expression (math_errhandling  &  MATH_ERRNO)
68                   is  non-zero,  then  errno  shall be set to [EDOM].  If the
69                   integer expression (math_errhandling &  MATH_ERREXCEPT)  is
70                   non-zero,  then  the invalid floating-point exception shall
71                   be raised.
72
73       These functions may fail if:
74
75       Domain Error
76                   The correct value is not representable as an integer.
77
78                   If the integer expression (math_errhandling  &  MATH_ERRNO)
79                   is  non-zero,  then  errno  shall be set to [EDOM].  If the
80                   integer expression (math_errhandling &  MATH_ERREXCEPT)  is
81                   non-zero,  then  the invalid floating-point exception shall
82                   be raised.
83
84       The following sections are informative.
85

EXAMPLES

87       None.
88

APPLICATION USAGE

90       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
91       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
92       at least one of them must be non-zero.
93

RATIONALE

95       These functions provide  floating-to-integer  conversions.  They  round
96       according  to  the  current rounding direction. If the rounded value is
97       outside the range of the return type, the numeric result is unspecified
98       and  the invalid floating-point exception is raised. When they raise no
99       other floating-point exception and the result differs  from  the  argu‐
100       ment, they raise the inexact floating-point exception.
101

FUTURE DIRECTIONS

103       None.
104

SEE ALSO

106       feclearexcept(), fetestexcept(), llrint()
107
108       The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of
109       Error Conditions for Mathematical Functions, <math.h>
110
112       Portions of this text are reprinted and reproduced in  electronic  form
113       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
114       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
115       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
116       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
117       event of any discrepancy between this version and the original IEEE and
118       The Open Group Standard, the original IEEE and The Open Group  Standard
119       is  the  referee document. The original Standard can be obtained online
120       at http://www.opengroup.org/unix/online.html .
121
122       Any typographical or formatting errors that appear  in  this  page  are
123       most likely to have been introduced during the conversion of the source
124       files to man page format. To report such errors,  see  https://www.ker
125       nel.org/doc/man-pages/reporting_bugs.html .
126
127
128
129IEEE/The Open Group                  2017                            LRINT(3P)
Impressum