*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> infnan (3)              
Title
Content
Arch
Section
 

INFNAN(3)

Contents


NAME    [Toc]    [Back]

     infnan - signals invalid floating-point operations on a  VAX
(temporary)

SYNOPSIS    [Toc]    [Back]

     #include <math.h>

     double
     infnan(int iarg);

DESCRIPTION    [Toc]    [Back]

     At some time in the future, some of the useful properties of
the Infinities
 and NaNs in the IEEE standard 754 for Binary  FloatingPoint Arithmetic
  will be simulated in UNIX on the DEC VAX by using its
Reserved
     Operands.  Meanwhile, the Invalid, Overflow  and  Divide-byZero exceptions
     of  the  IEEE  standard  are  being approximated on a VAX by
calls to a procedure
 infnan() in appropriate places in libm.  (See math(3)).
When better
     exception-handling  is  implemented  in  UNIX, only infnan()
among the codes
     in libm will have to be changed.  And users of libm can  design their own
     infnan() now to insulate themselves from future changes.

     Whenever an elementary function code in libm has to simulate
one of the
     aforementioned IEEE exceptions, it calls  infnan(iarg)  with
an appropriate
     value of iarg.  Then a reserved operand fault stops computation.  But
     infnan() could be replaced by a function with the same  name
that returns
     some  plausible  value,  assigns  an apt value to the global
variable errno,
     and allows computation to resume.   Alternatively,  the  Reserved Operand
     Fault  Handler could be changed to respond by returning that
plausible
     value, etc., instead of aborting.

     In the table below, the first two columns show  various  exceptions signaled
  by  the IEEE standard, and the default result it prescribes.  The
     third column shows what value is given to iarg by  functions
in libm when
     they  invoke infnan(iarg) under analogous circumstances on a
VAX.  Currently
 infnan() stops computation under  all  those  circumstances.  The
     last  two  columns offer an alternative; they suggest a setting for errno
     and a value for a revised infnan() to return.  And a C  program to implement
 that suggestion follows.


           IEEE   Signal   IEEE   Default      iarg         errno
infnan()
           Invalid        NaN                EDOM            EDOM
0
           Overflow       +-Infinity         ERANGE        ERANGE
HUGE
           Div-by-0     +-Infinity       +-ERANGE     ERANGE/EDOM
+-HUGE
                       (HUGE = 1.7e38 ... nearly  2.0**127)

     ALTERNATIVE infnan():

           #include <math.h>
           #include <errno.h>

           double
           infnan(iarg)
           int iarg;
           {
                   switch (iarg) {
                   case  ERANGE:
                           errno = ERANGE;
                           return (HUGE);
                   case -ERANGE:
                           errno = EDOM;
                           return (-HUGE);
                   default:
                           errno = EDOM;
                           return (0);
                   }
           }

SEE ALSO    [Toc]    [Back]

      
      
     intro(2), math(3), signal(3)

     ERANGE and EDOM are defined in <errno.h>.  (See intro(2) for
explanation
     of EDOM and ERANGE.)

HISTORY    [Toc]    [Back]

     The infnan() function appeared in 4.3BSD.

OpenBSD      3.6                           June      4,      1993
[ Back ]
 Similar pages
Name OS Title
fpgetmask IRIX floating-point units
drem Tru64 Compute the floating-point remainder
fmodf FreeBSD floating-point remainder functions
fabsf FreeBSD floating-point absolute value functions
fmod FreeBSD floating-point remainder functions
fabs FreeBSD floating-point absolute value functions
itrunc Tru64 truncate a floating-point number
fmod Tru64 Compute the floating-point remainder
ldexp Tru64 Manipulate floating-point numbers
logb Tru64 Manipulate floating-point numbers
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service