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