The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | .\" Copyright (c) 2004 David Schultz <das@FreeBSD.org> |
| 2 | .\" All rights reserved. |
| 3 | .\" |
| 4 | .\" Redistribution and use in source and binary forms, with or without |
| 5 | .\" modification, are permitted provided that the following conditions |
| 6 | .\" are met: |
| 7 | .\" 1. Redistributions of source code must retain the above copyright |
| 8 | .\" notice, this list of conditions and the following disclaimer. |
| 9 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| 10 | .\" notice, this list of conditions and the following disclaimer in the |
| 11 | .\" documentation and/or other materials provided with the distribution. |
| 12 | .\" |
| 13 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 14 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 16 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 17 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 18 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 19 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 20 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 21 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 22 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 23 | .\" SUCH DAMAGE. |
| 24 | .\" |
| 25 | .\" $FreeBSD: src/lib/msun/man/fegetenv.3,v 1.1 2004/06/06 10:06:26 das Exp $ |
| 26 | .\" |
| 27 | .Dd May 8, 2004 |
| 28 | .Dt FEGETENV 3 |
| 29 | .Os |
| 30 | .Sh NAME |
| 31 | .Nm fegetenv , |
| 32 | .Nm feholdexcept , |
| 33 | .Nm fesetenv , |
| 34 | .Nm feupdateenv |
| 35 | .Nd floating-point environment save and restore |
| 36 | .Sh LIBRARY |
| 37 | .Lb libm |
| 38 | .Sh SYNOPSIS |
| 39 | .In fenv.h |
| 40 | .Fd "#pragma STDC FENV_ACCESS ON" |
| 41 | .Ft int |
| 42 | .Fn fegetenv "fenv_t *envp" |
| 43 | .Ft int |
| 44 | .Fn feholdexcept "fenv_t *envp" |
| 45 | .Ft int |
| 46 | .Fn fesetenv "const fenv_t *envp" |
| 47 | .Ft int |
| 48 | .Fn feupdateenv "const fenv_t *envp" |
| 49 | .Sh DESCRIPTION |
| 50 | The floating-point environment includes exception flags and masks, the |
| 51 | current rounding mode, and other architecture-specific settings. |
| 52 | However, it does not include the floating-point register file. |
| 53 | .Pp |
| 54 | The |
| 55 | .Fn fegetenv |
| 56 | function stores the current floating-point environment in the object |
| 57 | pointed to by |
| 58 | .Fa envp , |
| 59 | whereas |
| 60 | .Fn feholdexcept |
| 61 | saves the current environment, then clears all exception flags |
| 62 | and masks all floating-point exceptions. |
| 63 | .Pp |
| 64 | The |
| 65 | .Fn fesetenv |
| 66 | function restores a previously saved environment. |
| 67 | The |
| 68 | .Fn feupdateenv |
| 69 | function restores a saved environment as well, but it also |
| 70 | raises any exceptions that were set in the environment it |
| 71 | replaces. |
| 72 | .Pp |
| 73 | The |
| 74 | .Fn feholdexcept |
| 75 | function is often used with |
| 76 | .Fn feupdateenv |
| 77 | or |
| 78 | .Fn fesetenv |
| 79 | to suppress spurious exceptions that occur as a result of |
| 80 | intermediate computations. |
| 81 | An example in |
| 82 | .Xr fenv 3 |
| 83 | demonstrates how to do this. |
| 84 | .Sh RETURN VALUES |
| 85 | The |
| 86 | .Fn fegetenv , |
| 87 | .Fn feholdexcept , |
| 88 | .Fn fesetenv , |
| 89 | and |
| 90 | .Fn feupdateenv |
| 91 | functions return 0 if they succeed, and non-zero otherwise. |
| 92 | .Sh SEE ALSO |
| 93 | .Xr feclearexcept 3 , |
| 94 | .Xr fenv 3 , |
| 95 | .Xr feraiseexcept 3 , |
| 96 | .Xr fesetenv 3 , |
| 97 | .Xr fetestexcept 3 , |
| 98 | .Xr fpgetmask 3 , |
| 99 | .Xr fpgetprec 3 , |
| 100 | .Xr fpsetmask 3 , |
| 101 | .Xr fpsetprec 3 |
| 102 | .Sh STANDARDS |
| 103 | The |
| 104 | .Fn fegetenv , |
| 105 | .Fn feholdexcept , |
| 106 | .Fn fesetenv , |
| 107 | and |
| 108 | .Fn feupdateenv |
| 109 | functions conform to |
| 110 | .St -isoC-99 . |
| 111 | .Sh HISTORY |
| 112 | These routines first appeared in |
| 113 | .Fx 5.3 . |