From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/numeric%2Fmath%2Froundeven.html | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 devdocs/c/numeric%2Fmath%2Froundeven.html (limited to 'devdocs/c/numeric%2Fmath%2Froundeven.html') diff --git a/devdocs/c/numeric%2Fmath%2Froundeven.html b/devdocs/c/numeric%2Fmath%2Froundeven.html new file mode 100644 index 00000000..418b93ae --- /dev/null +++ b/devdocs/c/numeric%2Fmath%2Froundeven.html @@ -0,0 +1,57 @@ +

roundeven, roundevenf, roundevenl

Defined in header <math.h>
float       roundevenf( float arg );
+
(1) (since C23)
double      roundeven( double arg );
+
(2) (since C23)
long double roundevenl( long double arg );
+
(3) (since C23)
Defined in header <tgmath.h>
#define roundeven( arg )
+
(4) (since C23)
+1-3) Computes the nearest integer value to arg (in floating-point format), rounding halfway cases to nearest even integer, regardless of the current rounding mode.
+4) Type-generic macro: If arg has type long double, roundevenl is called. Otherwise, if arg has integer type or the type double, roundeven is called. Otherwise, roundevenf is called, respectively.

Parameters

+ +
arg - floating point value

Return value

If no errors occur, the nearest integer value to arg, rounding halfway cases to nearest even integer, is returned.

+

Error handling

This function is not subject to any of the errors specified in math_errhandling.

+

If the implementation supports IEEE floating-point arithmetic (IEC 60559),

+

Example

#include <math.h>
+#include <stdio.h>
+int main(void)
+{
+    printf("roundeven(+2.4) = %+.1f\n", roundeven(2.4));
+    printf("roundeven(-2.4) = %+.1f\n", roundeven(-2.4));
+    printf("roundeven(+2.5) = %+.1f\n", roundeven(2.5));
+    printf("roundeven(-2.5) = %+.1f\n", roundeven(-2.5));
+    printf("roundeven(+2.6) = %+.1f\n", roundeven(2.6));
+    printf("roundeven(-2.6) = %+.1f\n", roundeven(-2.6));
+    printf("roundeven(+3.5) = %+.1f\n", roundeven(3.5));
+    printf("roundeven(-3.5) = %+.1f\n", roundeven(-3.5));
+    printf("roundeven(-0.0) = %+.1f\n", roundeven(-0.0));
+    printf("roundeven(-Inf) = %+f\n",   roundeven(-INFINITY));
+}

Possible output:

+
roundeven(+2.4) = +2.0
+roundeven(-2.4) = -2.0
+roundeven(+2.5) = +2.0
+roundeven(-2.5) = -2.0
+roundeven(+2.6) = +3.0
+roundeven(-2.6) = -3.0
+roundeven(+3.5) = +4.0
+roundeven(-3.5) = -4.0
+roundeven(-0.0) = -0.0
+roundeven(-Inf) = -inf

References

See also

+ +
+
(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)
rounds to an integer using current rounding mode with
exception if the result differs
(function)
+
(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)
rounds to nearest integer, rounding away from zero in halfway cases
(function)
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/numeric/math/roundeven +

+
-- cgit v1.2.3