fenv - phpMan

Command: man perldoc info search(apropos)  


FENV(3)                    Linux Programmer's Manual                   FENV(3)



NAME
       feclearexcept,   fegetexceptflag,   feraiseexcept,  fesetexceptflag,  fetestexcept,
       fegetenv, fegetround, feholdexcept, fesetround, fesetenv, feupdateenv - C99  float-
       ing point rounding and exception handling

SYNOPSIS
       #include <fenv.h>

       int feclearexcept(int excepts);
       int fegetexceptflag(fexcept_t *flagp, int excepts);
       int feraiseexcept(int excepts);
       int fesetexceptflag(const fexcept_t *flagp, int excepts);
       int fetestexcept(int excepts);

       int fegetround(void);
       int fesetround(int rounding_mode);

       int fegetenv(fenv_t *envp);
       int feholdexcept(fenv_t *envp);
       int fesetenv(const fenv_t *envp);
       int feupdateenv(const fenv_t *envp);

DESCRIPTION
       These  eleven  functions were defined in C99, and describe the handling of floating
       point rounding and exceptions (overflow, zero-divide etc.).

   Exceptions
       The DivideByZero exception occurs when an  operation  on  finite  numbers  produces
       infinity as exact answer.

       The  Overflow  exception  occurs  when a result has to be represented as a floating
       point number, but has (much) larger absolute value than the largest (finite) float-
       ing point number that is representable.

       The  Underflow  exception  occurs when a result has to be represented as a floating
       point number, but has smaller absolute value than the smallest positive  normalized
       floating point number (and would lose much accuracy when represented as a denormal-
       ized number).

       The Inexact exception occurs when the rounded result of an operation is  not  equal
       to  the  infinite  precision  result.   It may occur whenever Overflow or Underflow
       occurs.

       The Invalid exception occurs when there is no well-defined result for an operation,
       as for 0/0 or infinity - infinity or sqrt(-1).

   Exception handling
       Exceptions are represented in two ways: as a single bit (exception present/absent),
       and these bits correspond in some implementation-defined way with bit positions  in
       an integer, and also as an opaque structure that may contain more information about
       the exception (perhaps the code address where it occurred).

       Each of the macros FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW,  FE_UNDERFLOW
       is  defined  when  the implementation supports handling of the corresponding excep-
       tion, and if so then defines the corresponding bit(s), so that one can call  excep-
       tion  handling  functions e.g. using the integer argument FE_OVERFLOW|FE_UNDERFLOW.
       Other exceptions may be supported. The macro FE_ALL_EXCEPT is the bitwise OR of all
       bits corresponding to supported exceptions.

       The  feclearexcept()  function  clears  the supported exceptions represented by the
       bits in its argument.

       The fegetexceptflag() function stores a representation of the state of  the  excep-
       tion flags represented by the argument excepts in the opaque object *flagp.

       The  feraiseexcept()  function  raises  the supported exceptions represented by the
       bits in excepts.

       The fesetexceptflag() function sets the complete status for the  exceptions  repre-
       sented  by  excepts  to the value *flagp.  This value must have been obtained by an
       earlier call of fegetexceptflag() with a last argument that contained all  bits  in
       excepts.

       The  fetestexcept() function returns a word in which the bits are set that were set
       in the argument excepts and for which the corresponding exception is currently set.

   Rounding
       Each  of  the macros FE_DOWNWARD, FE_TONEAREST, FE_TOWARDZERO, FE_UPWARD is defined
       when the implementation supports getting and  setting  the  corresponding  rounding
       direction.

       The  fegetround()  function returns the macro corresponding to the current rounding
       mode.

       The fesetround() function sets the rounding mode as specified by its  argument  and
       returns zero when it was successful.

   Floating point environment
       The  entire  floating  point environment, including control modes and status flags,
       can be handled as one opaque object, of type fenv_t.  The  default  environment  is
       denoted  by  FE_DFL_ENV (of type const fenv_t *).  This is the environment setup at
       program start and it is defined by ISO C to have round to nearest,  all  exceptions
       cleared and a non-stop (continue on exceptions) mode.

       The  fegetenv() function saves the current floating point environment in the object
       *envp.

       The feholdexcept() function does the same, then clears  all  exception  flags,  and
       sets  a  non-stop (continue on exceptions) mode, if available. It returns zero when
       successful.

       The fesetenv() function restores the floating point  environment  from  the  object
       *envp.   This  object  must  be  known  to  be valid, e.g., the result of a call to
       fegetenv() or feholdexcept() or equal to FE_DFL_ENV.   This  call  does  not  raise
       exceptions.

       The  feupdateenv()  function installs the floating-point environment represented by
       the object *envp, except that currently raised exceptions are not  cleared.   After
       calling  this  function, the raised exceptions will be a bitwise OR of those previ-
       ously set with those in *envp.  As before, the object *envp must  be  known  to  be
       valid.

RETURN VALUE
       These functions return zero on success and non-zero if an error occurred.

GNU DETAILS
       If  possible,  the  GNU C Library defines a macro FE_NOMASK_ENV which represents an
       environment where every exception raised causes a trap to occur.  You can test  for
       this  macro  using  #ifdef.  It is only defined if _GNU_SOURCE is defined.  The C99
       standard does not define a way to set individual bits in the floating  point  mask,
       e.g.  to trap on specific flags.  glibc 2.2 supports the functions feenableexcept()
       and fedisableexcept() to set individual floating point traps, and fegetexcept()  to
       query the state.

       #define _GNU_SOURCE
       #include <fenv.h>

       int feenableexcept (int excepts);
       int fedisableexcept (int excepts);
       int fegetexcept (void);

       The  feenableexcept()  and  fedisableexcept()  functions enable (disable) traps for
       each of the exceptions represented by  excepts  and  return  the  previous  set  of
       enabled  exceptions  when successful, and -1 otherwise.  The fegetexcept() function
       returns the set of all currently enabled exceptions.

NOTES
       Link with -lm.

CONFORMING TO
       IEC 60559 (IEC 559:1989), ANSI/IEEE 854, C99.



Linux Manpage                     2000-08-12                           FENV(3)

Generated by $Id: phpMan.php,v 4.49 2006/02/26 13:18:18 chedong Exp $ Author: Che Dong
On Apache/1.3.37 (Unix) mod_throttle/3.1.2 FrontPage/5.0.2.2635 mod_psoft_traffic/0.2 mod_ssl/2.8.28 OpenSSL/0.9.8b
Under GNU General Public License
2008-11-21 08:25 @38.103.63.55 Crawled by CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
Valid XHTML 1.0!Valid CSS!