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
22

DESCRIPTION

24       These  functions  shall  round  their  argument  to the nearest integer
25       value, rounding according to the current rounding direction.
26
27       An application wishing to check for error situations should  set  errno
28       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
29       functions.  On return, if errno is non-zero or  fetestexcept(FE_INVALID
30       |  FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
31       occurred.
32

RETURN VALUE

34       Upon successful completion, these functions shall  return  the  rounded
35       integer value.
36
37       If  x  is  NaN,  a domain error shall occur and an unspecified value is
38       returned.
39
40       If x is +Inf, a domain error shall occur and an  unspecified  value  is
41       returned.
42
43       If  x  is  -Inf, a domain error shall occur and an unspecified value is
44       returned.
45
46       If the correct value is positive and too large to represent as a  long,
47       a domain error shall occur and an unspecified value is returned.
48
49       If  the correct value is negative and too large to represent as a long,
50       a domain error shall occur and an unspecified value is returned.
51

ERRORS

53       These functions shall fail if:
54
55       Domain Error
56              The x argument is NaN or ±Inf, or the correct value is not  rep‐
57              resentable as an integer.
58
59       If  the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
60       then  errno  shall  be  set  to  [EDOM].  If  the  integer   expression
61       (math_errhandling  &  MATH_ERREXCEPT)  is  non-zero,  then  the invalid
62       floating-point exception shall be raised.
63
64
65       The following sections are informative.
66

EXAMPLES

68       None.
69

APPLICATION USAGE

71       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
72       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
73       at least one of them must be non-zero.
74

RATIONALE

76       These functions provide  floating-to-integer  conversions.  They  round
77       according  to  the  current rounding direction. If the rounded value is
78       outside the range of the return type, the numeric result is unspecified
79       and  the invalid floating-point exception is raised. When they raise no
80       other floating-point exception and the result differs  from  the  argu‐
81       ment, they raise the inexact floating-point exception.
82

FUTURE DIRECTIONS

84       None.
85

SEE ALSO

87       feclearexcept(),  fetestexcept(), llrint(), the Base Definitions volume
88       of IEEE Std 1003.1-2001, Section 4.18, Treatment  of  Error  Conditions
89       for Mathematical Functions, <math.h>
90
92       Portions  of  this text are reprinted and reproduced in electronic form
93       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
94       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
95       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
96       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
97       event of any discrepancy between this version and the original IEEE and
98       The  Open Group Standard, the original IEEE and The Open Group Standard
99       is the referee document. The original Standard can be  obtained  online
100       at http://www.opengroup.org/unix/online.html .
101
102
103
104IEEE/The Open Group                  2003                            LRINT(3P)
Impressum