1.\"	$OpenBSD: fegetround.3,v 1.3 2013/06/05 03:40:26 tedu Exp $
2.\"
3.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 5 2013 $
18.Dt FEGETROUND 3
19.Os
20.Sh NAME
21.Nm fegetround ,
22.Nm fesetround
23.Nd control floating-point rounding direction modes
24.Sh SYNOPSIS
25.In fenv.h
26.Ft int
27.Fn fegetround void
28.Ft int
29.Fn fesetround "int round"
30.Sh DESCRIPTION
31These functions provide control of floating-point rounding direction
32modes.
33The
34.Fa round
35input argument is a value specifying a rounding direction mode and
36containing any of the values listed below.
37.Bl -tag -width ".Dv FE_TOWARDZERO"
38.It Dv FE_TONEAREST
39Results are rounded to the closest representable value.
40If the exact result is exactly half way between two representable
41values, the value whose last binary digit is even (zero) is chosen.
42This is the default mode.
43.It Dv FE_DOWNWARD
44Results are rounded towards negative \*[If].
45.It Dv FE_UPWARD
46Results are rounded towards positive \*[If].
47.It Dv FE_TOWARDZERO
48Results are rounded towards zero.
49.El
50.Pp
51The
52.Fn fegetround
53function gets the current rounding direction.
54.Pp
55The
56.Fn fesetround
57function establishes the rounding direction represented by
58.Pa round .
59If the argument is not equal to the value of a rounding direction
60macro, the rounding direction is not changed.
61.Sh RETURN VALUES
62The
63.Fn fegetround
64function returns the current rounding direction.
65The
66.Fn fesetround
67function return zero on success, and non-zero if an error occurred.
68.Sh SEE ALSO
69.Xr feclearexcept 3 ,
70.Xr feenableexcept 3 ,
71.Xr fegetenv 3
72.Sh STANDARDS
73The
74.Fn fegetround
75and
76.Fn fesetround
77functions conform to
78.St -isoC-99 .
79.Sh HISTORY
80These functions first appeared in
81.Ox 5.0 .
82