Go to main content
Oracle Developer Studio 12.6 Man Pages

Exit Print View

Updated: June 2017
 
 

ieee_environment(3F)

Name

ieee_environment - mode, status, and signal handling for IEEE arithmetic

Synopsis

#include "floatingpoint.h"
integer*4 function ieee_flags(action,mode,in,out)
character*(*) action, mode, in, out
integer*4 function ieee_handler(action,exception,hdl)
character*(*) action, exception
sigfpe_handler_type hdl
sigfpe_handler_type function sigfpe(code, hdl)
sigfpe_code_type code
sigfpe_handler_type hdl

Description

These subprograms provide modes and status required to fully exploit ANSI/IEEE Standard 754-1985 arithmetic in a FORTRAN program. They correspond closely to the functions ieee_flags(3M), ieee_handler(3M), and sigfpe(3C).

Usage

Example 1: Set rounding direction to round toward zero, unless the hardware does not support directed rounding modes:

 
integer*4 ieeer
character*1 mode, out, in
ieeer = ieee_flags('set', 'direction', 'tozero', out)

Example 2: Clear rounding direction to default, round toward nearest:

 
character*1 out, in
ieeer = ieee_flags('clear','direction', in, out)

Example 3: Clear all accrued exception-occurred bits:

 
character*16 out
ieeer = ieee_flags('clear','exception','all',out)

Example 4: If example 3 generates the overflow exception, detect the exception as follows:

 
character*16 out
ieeer = ieee_flags('get','exception','overflow', out)

Example 5: A user-specified signal handler, with a main program to use it:

 
    external hand
    real r / 14.2 /,  s / 0.0 /
    i = ieee_handler( 'set', 'division', hand )
    t = r/s
    end

    integer function hand ( sig, sip, uap )
    integer sig, address
    structure /fault/
         integer address
    end structure

    structure /siginfo/
         integer si_signo
         integer si_code
         integer si_errno
         record /fault/ fault
    end structure

    record /siginfo/ sip

    address = sip.fault.address
    write (*,10) address
10  format('Exception at hex address ', z8 )
    end
     
      

See Also

floatingpoint(3F), signal(3C), sigfpe(3C), ieee_handler(3M)

Numerical Computation Guide