Oracle Solaris Studio 12.4 Man Pages

Exit Print View

Updated: January 2015
 
 

ieee_environment(3F)

Name

ieee_environment - IEEE 算法的模式、状态和信号处理

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

这些子程序提供了在 FORTRAN 程序中充分利用 ANSI/IEEE 标准 754-1985 算法所需的模式和状态。它们近似对应于函数 ieee_flags(3m)、ieee_handler(3m) 和 sigfpe(3C)。

Usage

示例 1:将舍入方向设置为朝零舍入,除非硬件不支持定向的舍入模式:

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

示例 2:将舍入方向清除为缺省值,即朝最接近的值舍入:

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

示例 3:清除所有已发生的引发了异常的位:

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

示例 4:如果示例 3 生成了溢出异常,则按以下方式检测异常:

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

示例 5:用户指定的信号处理程序,通过一个主程序使用它:

 
    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)

数值计算指南