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/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
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.
25 .\" This notice shall appear on any product containing this material.
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.
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.
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]
43 .\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
46 .TH FENV.H 3HEAD "Dec 15, 2003"
48 fenv.h, fenv \- floating-point environment
52 #include <\fBfenv.h\fR>
58 The <\fBfenv.h\fR> header defines the following data types through
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.
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.
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
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:
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.
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.
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.)
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
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.
191 A function call is assumed to require default floating-point control modes,
192 unless its documentation promises otherwise.
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
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
218 #pragma STDC FENV_ACCESS ON
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:
238 #pragma STDC FENV_ACCESS ON
245 See \fBattributes\fR(5) for descriptions of the following attributes:
253 ATTRIBUTE TYPE ATTRIBUTE VALUE
255 Interface Stability Standard
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),