1 .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH round 3 (date) "Linux man-pages (unreleased)"
9 round, roundf, roundl \- round to nearest integer, away from zero
12 .RI ( libm ", " \-lm )
17 .BI "double round(double " x );
18 .BI "float roundf(float " x );
19 .BI "long double roundl(long double " x );
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
31 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
36 to the nearest integer, but
37 round halfway cases away from zero (regardless of the current rounding
40 instead of to the nearest even integer like
49 These functions return the rounded integer value.
53 is integral, +0, \-0, NaN, or infinite,
58 POSIX.1-2001 documents a range error for overflows, but see NOTES.
60 These functions first appeared in glibc in version 2.1.
62 For an explanation of the terms used in this section, see
70 Interface Attribute Value
75 T} Thread safety MT-Safe
81 C99, POSIX.1-2001, POSIX.1-2008.
83 POSIX.1-2001 contains text about overflow (which might set
90 In practice, the result cannot overflow on any current machine,
91 so this error-handling stuff is just nonsense.
92 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
93 (More precisely, overflow can happen only when the maximum value
94 of the exponent is smaller than the number of mantissa bits.
95 For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
96 the maximum value of the exponent is 127 (respectively, 1023),
97 and the number of mantissa bits
98 including the implicit bit
99 is 24 (respectively, 53).)
101 If you want to store the rounded value in an integer type,
102 you probably want to use one of the functions described in