.\" @(#)f77_ieee_environment.3f 1.2 88/03/19 SMI; .TH F77_IEEE_ENVIRONMENT 3F "98/09/16" .SH NAME f77_ieee_environment \- mode, status, and signal handling for IEEE arithmetic .SH SYNOPSIS .\" .IX f77_ieee_environment "" \fLf77_ieee_environment\fP .IX ieee environment \s-1IEEE\s0 environment .IX mode ieee "" \s-1IEEE\s0 .IX status ieee "" \s-1IEEE\s0 .IX "signals ieee" "" "signals \s-1IEEE\s0" .IX "ieee_flags" .IX "ieee_handler" .\" .B #include .PP .B integer*4 function ieee_flags(action,mode,in,out) .br .B character*(*) action, mode, in, out .PP .B integer*4 function ieee_handler(action,exception,hdl) .br .B character*(*) action, exception .br .B sigfpe_handler_type hdl .PP .B sigfpe_handler_type function sigfpe(code, hdl) .br .B sigfpe_code_type code .br .B sigfpe_handler_type hdl .PP .SH 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 .BR ieee_flags (3M), .BR ieee_handler (3M), and .BR sigfpe (3). .\" .SH USAGE .\" .\"All alphabetic string arguments .\".I must .\"be lower case. .\".sp Example 1: Set rounding direction to round toward zero, unless the hardware does not support directed rounding modes: .sp .nf .ft 3 integer*4 ieeer character*1 mode, out, in ieeer = ieee_flags('set', 'direction', 'tozero', out) .ft 1 .fi .sp Example 2: Clear rounding direction to default, round toward nearest: .sp .nf .ft 3 character*1 out, in ieeer = ieee_flags('clear','direction', in, out) .ft 1 .fi .sp Example 3: Clear all accrued exception-occurred bits: .sp .nf .ft 3 character*16 out ieeer = ieee_flags('clear','exception','all',out) .ft 1 .fi .sp Example 4: If example 3 generates the overflow exception, detect the exception as follows: .sp .nf .ft 3 character*16 out ieeer = ieee_flags('get','exception','overflow', out) .ft 1 .fi .bp Example 5: A user-specified signal handler, with a main program to use it: .sp .nf .ft 3 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 .ft 1 .fi .\" .SH FILES .\" .B include/f77/f77_floatingpoint.h .br .B libm.a .SH "SEE ALSO" .BR floatingpoint (3), .BR signal (3), .BR sigfpe (3), .BR f77_floatingpoint (3F), .BR ieee_flags (3M), .BR ieee_handler (3M), and the .I "Numerical Computation Guide"