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(): _XOPEN_SOURCE >= 600 ||
25       _ISOC99_SOURCE; or cc -std=c99
26       rint(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
27       _ISOC99_SOURCE; or cc -std=c99
28       rintf(), rintl(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600
29       || _ISOC99_SOURCE; or cc -std=c99
30

DESCRIPTION

32       The  nearbyint()  functions round their argument to an integer value in
33       floating-point format, using the current rounding direction  (see  fes‐
34       etround(3)) and without raising the inexact exception.
35
36       The  rint() functions do the same, but will raise the inexact exception
37       (FE_INEXACT, checkable via fetestexcept(3)) when the result differs  in
38       value from the argument.
39

RETURN VALUE

41       These functions return the rounded integer value.
42
43       If x is integral, +0, -0, NaN, or infinite, x itself is returned.
44

ERRORS

46       No  errors  occur.  POSIX.1-2001 documents a range error for overflows,
47       but see NOTES.
48

CONFORMING TO

50       C99, POSIX.1-2001.
51

NOTES

53       SUSv2 and POSIX.1-2001 contain text about  overflow  (which  might  set
54       errno  to ERANGE, or raise an FE_OVERFLOW exception).  In practice, the
55       result cannot overflow on any current machine, so  this  error-handling
56       stuff is just nonsense.  (More precisely, overflow can happen only when
57       the maximum value of the exponent is smaller than the  number  of  man‐
58       tissa bits.  For the IEEE-754 standard 32-bit and 64-bit floating-point
59       numbers the maximum value of the exponent is 128 (respectively,  1024),
60       and the number of mantissa bits is 24 (respectively, 53).)
61
62       If you want to store the rounded value in an integer type, you probably
63       want to use one of the functions described in lrint(3) instead.
64

SEE ALSO

66       ceil(3), floor(3), lrint(3), round(3), trunc(3)
67

COLOPHON

69       This page is part of release 3.25 of the Linux  man-pages  project.   A
70       description  of  the project, and information about reporting bugs, can
71       be found at http://www.kernel.org/doc/man-pages/.
72
73
74
75                                  2008-08-05                           RINT(3)
Impressum