1RINT(3)                    Linux Programmer's Manual                   RINT(3)
2
3
4

NAME

6       nearbyint,  nearbyintf, nearbyintl, rint, rintf, rintl - round to near‐
7       est integer
8

SYNOPSIS

10       #include <math.h>
11
12       double nearbyint(double x);
13       float nearbyintf(float x);
14       long double nearbyintl(long double x);
15
16       double rint(double x);
17       float rintf(float x);
18       long double rintl(long double x);
19
20       Link with -lm.
21
22   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
23
24       nearbyint(), nearbyintf(), nearbyintl():
25           _POSIX_C_SOURCE >= 200112L || _ISOC99_SOURCE
26       rint():
27           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
28               || _XOPEN_SOURCE >= 500
29               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
30               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
31       rintf(), rintl():
32           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
33               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
34               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
35

DESCRIPTION

37       The nearbyint(), nearbyintf(), and nearbyintl() functions  round  their
38       argument  to  an integer value in floating-point format, using the cur‐
39       rent rounding direction (see fesetround(3)) and without raising the in‐
40       exact  exception.   When  the current rounding direction is to nearest,
41       these functions round halfway cases to the even integer  in  accordance
42       with IEEE-754.
43
44       The  rint(), rintf(), and rintl() functions do the same, but will raise
45       the inexact exception (FE_INEXACT, checkable via fetestexcept(3))  when
46       the result differs in value from the argument.
47

RETURN VALUE

49       These functions return the rounded integer value.
50
51       If x is integral, +0, -0, NaN, or infinite, x itself is returned.
52

ERRORS

54       No  errors  occur.  POSIX.1-2001 documents a range error for overflows,
55       but see NOTES.
56

ATTRIBUTES

58       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
59       tributes(7).
60
61       ┌───────────────────────────┬───────────────┬─────────┐
62Interface                  Attribute     Value   
63       ├───────────────────────────┼───────────────┼─────────┤
64nearbyint(), nearbyintf(), │ Thread safety │ MT-Safe │
65nearbyintl(), rint(),      │               │         │
66rintf(), rintl()           │               │         │
67       └───────────────────────────┴───────────────┴─────────┘

CONFORMING TO

69       C99, POSIX.1-2001, POSIX.1-2008.
70

NOTES

72       SUSv2 and POSIX.1-2001 contain text about overflow (which might set er‐
73       rno to ERANGE, or raise an FE_OVERFLOW exception).   In  practice,  the
74       result  cannot  overflow on any current machine, so this error-handling
75       stuff is just nonsense.  (More precisely, overflow can happen only when
76       the  maximum  value  of the exponent is smaller than the number of man‐
77       tissa bits.  For the IEEE-754 standard 32-bit and 64-bit floating-point
78       numbers  the maximum value of the exponent is 128 (respectively, 1024),
79       and the number of mantissa bits is 24 (respectively, 53).)
80
81       If you want to store the rounded value in an integer type, you probably
82       want to use one of the functions described in lrint(3) instead.
83

SEE ALSO

85       ceil(3), floor(3), lrint(3), round(3), trunc(3)
86

COLOPHON

88       This  page  is  part of release 5.10 of the Linux man-pages project.  A
89       description of the project, information about reporting bugs,  and  the
90       latest     version     of     this    page,    can    be    found    at
91       https://www.kernel.org/doc/man-pages/.
92
93
94
95                                  2017-09-15                           RINT(3)
Impressum