9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3head / fenv.h.3head
blobe730d7498ca486e941623c5824ec876ce08af2d1
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
45 .\"
46 .TH FENV.H 3HEAD "Dec 15, 2003"
47 .SH NAME
48 fenv.h, fenv \- floating-point environment
49 .SH SYNOPSIS
50 .LP
51 .nf
52 #include <\fBfenv.h\fR>
53 .fi
55 .SH DESCRIPTION
56 .sp
57 .LP
58 The <\fBfenv.h\fR> header defines the following data types through
59 \fBtypedef\fR:
60 .sp
61 .ne 2
62 .na
63 \fB\fBfenv_t\fR\fR
64 .ad
65 .RS 13n
66 Represents the entire floating-point environment. The floating-point
67 environment refers collectively to any floating-point status flags and control
68 modes supported by the implementation.
69 .RE
71 .sp
72 .ne 2
73 .na
74 \fB\fBfexcept_t\fR\fR
75 .ad
76 .RS 13n
77 Represents the floating-point status flags collectively, including any status
78 the implementation associates with the flags. A floating-point status flag is a
79 system variable whose value is set (but never cleared) when a floating-point
80 exception is raised, which occurs as a side effect of exceptional
81 floating-point arithmetic to provide auxiliary information. A floating-point
82 control mode is a system variable whose value can be set by the user to affect
83 the subsequent behavior of floating-point arithmetic.
84 .RE
86 .sp
87 .LP
88 The <\fBfenv.h\fR> header defines the following constants if and only if the
89 implementation supports the floating-point exception by means of the
90 floating-point functions \fBfeclearexcept()\fR, \fBfegetexceptflag()\fR,
91 \fBferaiseexcept()\fR, \fBfesetexceptflag()\fR,  and \fBfetestexcept()\fR. Each
92 expands to an integer constant expression with values such that
93 bitwise-inclusive ORs of all combinations of the constants result in distinct
94 values.
95 .sp
96 .in +2
97 .nf
98 FE_DIVBYZERO
99 FE_INEXACT
100 FE_INVALID
101 FE_OVERFLOW
102 FE_UNDERFLOW
104 .in -2
108 The <\fBfenv.h\fR> header defines the following constant, which is simply the
109 bitwise-inclusive OR of all floating-point exception constants defined above:
111 .in +2
113 FE_ALL_EXCEPT
115 .in -2
119 The <\fBfenv.h\fR> header defines the following constants. Each expands to an
120 integer constant expression whose values are distinct non-negative values.
122 .in +2
124 FE_DOWNWARD
125 FE_TONEAREST
126 FE_TOWARDZERO
127 FE_UPWARD
129 .in -2
133 The <\fBfenv.h\fR> header defines the following constant, which represents the
134 default floating-point environment (that is, the one installed at program
135 startup) and has type pointer to const-qualified \fBfenv_t\fR. It can be used
136 as an argument to the functions within the <\fBfenv.h\fR> header that manage
137 the floating-point environment.
139 .in +2
141 FE_DFL_ENV
143 .in -2
147 The \fBFENV_ACCESS\fR pragma provides a means to inform the implementation when
148 an application might access the floating-point environment to test
149 floating-point status flags or run under non-default floating-point control
150 modes. The pragma occurs either outside external declarations or preceding all
151 explicit declarations and statements inside a compound statement. When outside
152 external declarations, the pragma takes effect from its occurrence until
153 another \fBFENV_ACCESS\fR pragma is encountered, or until the end of the
154 translation unit. When inside a compound statement, the pragma takes effect
155 from its occurrence until another \fBFENV_ACCESS\fR pragma is encountered
156 (including within a nested compound statement), or until the end of the
157 compound statement; at the end of a compound statement the state for the pragma
158 is restored to its condition just before the compound statement. If this pragma
159 is used in any other context, the behavior is undefined.
162 If part of an application tests floating-point status flags, sets
163 floating-point control modes, or runs under non-default mode settings, but was
164 translated with the state for the \fBFENV_ ACCESS\fR pragma off, the behavior
165 is undefined. The default state (on or off) for the pragma is
166 implementation-defined. (When execution passes from a part of the application
167 translated with \fBFENV_ACCESS\fR off to a part translated with
168 \fBFENV_ACCESS\fR on, the state of the floating-point status flags is
169 unspecified and the floating-point control modes have their default settings.)
170 .SH USAGE
173 This header is designed to support the floating-point exception status flags
174 and directed-rounding control modes required by the IEC 60559: 1989 standard,
175 and other similar floating-point state information. Also, it is designed to
176 facilitate code portability among all systems.  Certain application programming
177 conventions support the intended model of use for the floating-point
178 environment:
179 .RS +4
181 .ie t \(bu
182 .el o
183 A function call does not alter its caller's floating-point control modes, clear
184 its caller's floating-point status flags, or depend on the state of its
185 caller's floating-point status flags unless the function is so documented.
187 .RS +4
189 .ie t \(bu
190 .el o
191 A function call is assumed to require default floating-point control modes,
192 unless its documentation promises otherwise.
194 .RS +4
196 .ie t \(bu
197 .el o
198 A function call is assumed to have the potential for raising floating-point
199 exceptions, unless its documentation promises otherwise.
203 With these conventions, an application can safely assume default floating-point
204 control modes (or be unaware of them). The responsibilities associated with
205 accessing the floating-point environment fall on the application that does so
206 explicitly.
209 Even though the rounding direction macros might expand to constants
210 corresponding to the values of \fBFLT_ROUNDS\fR, they are not required to do
211 so. For example:
213 .in +2
215 #include <fenv.h>
216 void f(double x)
218     #pragma STDC FENV_ACCESS ON
219     void g(double);
220     void h(double);
221     /* ... */
222     g(x + 1);
223     h(x + 1);
224     /* ... */
227 .in -2
231 If the function \fIg\fR() might depend on status flags set as a side effect of
232 the first \fIx\fR+1, or if the second \fIx\fR+1 might depend on control modes
233 set as a side effect of the call to function \fIg\fR(), then the application
234 must contain an appropriately placed invocation as follows:
236 .in +2
238 #pragma STDC FENV_ACCESS ON
240 .in -2
242 .SH ATTRIBUTES
245 See \fBattributes\fR(5) for descriptions of the following attributes:
250 box;
251 c | c
252 l | l .
253 ATTRIBUTE TYPE  ATTRIBUTE VALUE
255 Interface Stability     Standard
258 .SH SEE ALSO
261 \fBfeclearexcept\fR(3M), \fBfegetenv\fR(3M), \fBfegetexceptflag\fR(3M),
262 \fBfegetround\fR(3M), \fBfeholdexcept\fR(3M), \fBferaiseexcept\fR(3M),
263 \fBfesetenv\fR(3M), \fBfesetexceptflag\fR(3M), \fBfesetround\fR(3M),
264 \fBfetestexcept\fR(3M), \fBfeupdateenv\fR(3M), \fBattributes\fR(5),
265 \fBstandards\fR(5)