xref: /openbsd-src/lib/libm/man/fegetround.3 (revision 961ae58b0647acb72809d3523955df3fa16862b9)
1*961ae58bSjmc.\"	$OpenBSD: fegetround.3,v 1.4 2020/11/14 10:35:58 jmc Exp $
2939fdbfbSmartynas.\"
3939fdbfbSmartynas.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
4939fdbfbSmartynas.\"
5939fdbfbSmartynas.\" Permission to use, copy, modify, and distribute this software for any
6939fdbfbSmartynas.\" purpose with or without fee is hereby granted, provided that the above
7939fdbfbSmartynas.\" copyright notice and this permission notice appear in all copies.
8939fdbfbSmartynas.\"
9939fdbfbSmartynas.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10939fdbfbSmartynas.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11939fdbfbSmartynas.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12939fdbfbSmartynas.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13939fdbfbSmartynas.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14939fdbfbSmartynas.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15939fdbfbSmartynas.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16939fdbfbSmartynas.\"
17*961ae58bSjmc.Dd $Mdocdate: November 14 2020 $
18939fdbfbSmartynas.Dt FEGETROUND 3
19939fdbfbSmartynas.Os
20939fdbfbSmartynas.Sh NAME
21939fdbfbSmartynas.Nm fegetround ,
22939fdbfbSmartynas.Nm fesetround
23939fdbfbSmartynas.Nd control floating-point rounding direction modes
24939fdbfbSmartynas.Sh SYNOPSIS
2586f9d4cdStedu.In fenv.h
26939fdbfbSmartynas.Ft int
27939fdbfbSmartynas.Fn fegetround void
28939fdbfbSmartynas.Ft int
29939fdbfbSmartynas.Fn fesetround "int round"
30939fdbfbSmartynas.Sh DESCRIPTION
31939fdbfbSmartynasThese functions provide control of floating-point rounding direction
32939fdbfbSmartynasmodes.
33939fdbfbSmartynasThe
34939fdbfbSmartynas.Fa round
35939fdbfbSmartynasinput argument is a value specifying a rounding direction mode and
36939fdbfbSmartynascontaining any of the values listed below.
37*961ae58bSjmc.Bl -tag -width "FE_TOWARDZERO"
38939fdbfbSmartynas.It Dv FE_TONEAREST
39939fdbfbSmartynasResults are rounded to the closest representable value.
40939fdbfbSmartynasIf the exact result is exactly half way between two representable
41939fdbfbSmartynasvalues, the value whose last binary digit is even (zero) is chosen.
42939fdbfbSmartynasThis is the default mode.
43939fdbfbSmartynas.It Dv FE_DOWNWARD
44939fdbfbSmartynasResults are rounded towards negative \*[If].
45939fdbfbSmartynas.It Dv FE_UPWARD
46939fdbfbSmartynasResults are rounded towards positive \*[If].
47939fdbfbSmartynas.It Dv FE_TOWARDZERO
48939fdbfbSmartynasResults are rounded towards zero.
49939fdbfbSmartynas.El
50939fdbfbSmartynas.Pp
51939fdbfbSmartynasThe
52939fdbfbSmartynas.Fn fegetround
53939fdbfbSmartynasfunction gets the current rounding direction.
54939fdbfbSmartynas.Pp
55939fdbfbSmartynasThe
56939fdbfbSmartynas.Fn fesetround
57939fdbfbSmartynasfunction establishes the rounding direction represented by
58939fdbfbSmartynas.Pa round .
59939fdbfbSmartynasIf the argument is not equal to the value of a rounding direction
60939fdbfbSmartynasmacro, the rounding direction is not changed.
61939fdbfbSmartynas.Sh RETURN VALUES
62939fdbfbSmartynasThe
63939fdbfbSmartynas.Fn fegetround
64939fdbfbSmartynasfunction returns the current rounding direction.
65939fdbfbSmartynasThe
66939fdbfbSmartynas.Fn fesetround
67939fdbfbSmartynasfunction return zero on success, and non-zero if an error occurred.
68939fdbfbSmartynas.Sh SEE ALSO
69939fdbfbSmartynas.Xr feclearexcept 3 ,
700fde9a44Sjmc.Xr feenableexcept 3 ,
710fde9a44Sjmc.Xr fegetenv 3
72939fdbfbSmartynas.Sh STANDARDS
73939fdbfbSmartynasThe
740fde9a44Sjmc.Fn fegetround
75939fdbfbSmartynasand
76939fdbfbSmartynas.Fn fesetround
77939fdbfbSmartynasfunctions conform to
78939fdbfbSmartynas.St -isoC-99 .
79939fdbfbSmartynas.Sh HISTORY
80939fdbfbSmartynasThese functions first appeared in
81939fdbfbSmartynas.Ox 5.0 .
82