the LCAS and C
Nelson H.F. Beebe
uunet!math.utah.edu!beebe
Wed May 8 14:22:15 PDT 1991
Paul Eggert writes:
>> ...
>> With respect to C and IEEE floating point, the major problems with the
>> Language Compatible Arithmetic Standard (LCAS) are notification and
>> documentation of translation. The first problem is the most severe,
>> because the LCAS is incompatible with the IEEE 754 default.
>> ...
The IBM RS/6000 IEEE 754 floating-point implementation is non-stop; no
exceptions are taken when Inf, NaN, or underflow are generated.
The only way to isolate the occurrence of one is to bracket statements
with calls to a library routine that tests a flags register for bits
indicating exceptional conditions. A portion of the relevant man page
is appended to this message.
>> ...
>> Section B.3 of the LCAS claims that `char' is always smaller than
>> `int', but the C standard does not support this claim, and permits
>> `char' to be the same size as `int'.
>> ...
An indeed, this has been the case. On the DEC-20, PCC-20 stores char,
short, int, and long as 36-bit fullword quantities. It seems likely
that other word-oriented architectures may have done the same. KCC-20
uses 9-bit bytes for char, and tight loops over char* arrays run a few
times faster with PCC than with KCC, because word-oriented accesses
faster than byte-oriented ones on that machine (even though it DOES
have byte access instructions).
========================================================================
Here is part of the output of "man fp_invalid_op" on the IBM RS/6000
(AIX 3.1); the point noted above is marked by the !! prefix:
>> ...
>> Purpose
>>
>> Tests to see if a floating-point exception has occurred.
>>
>> Syntax
>>
>> #include<float.h>
>> #include<fpxcp.h>
>>
>> int fp_invalid_op()
>> int fp_divbyzero()
>> int fp_overflow()
>> int fp_underflow()
>> int fp_inexact()
>> int fp_any_xcp()
>> int fp_iop_snan()
>> int fp_iop_infsinf()
>> int fp_iop_infdinf()
>> int fp_iop_zrdzr()
>> int fp_iop_infmzr()
>> int fp_iop_invcmp()
>>
>> Description
>>
!!>> The RISC System/6000 currently does not generate an interrupt
!!>> for floating-point exceptions. Therefore, the common method of
!!>> catching the signal SIGFPE and calling an appropriate trap
!!>> handler to identify the floating-point exception is not support-
!!>> ed.
>>
>> These subroutines aid in determining when an exception has
>> occurred and the exception type. These subroutines can be called
>> explicitly around blocks of code that may cause a floating-point
>> exception.
>>
>> Return Values
>>
>> The fp_invalid_op subroutine returns 1 if a floating-point
>> invalid operation exception status flag is set. Otherwise, 0 is
>> returned.
>>
>> The fp_divbyzero subroutine returns 1 if a floating-point
>> divide by zero exception status flag is set. Otherwise, 0 is re-
>> turned.
>>
>> The fp_overflow subroutine returns 1 if a floating-point
>> overflow exception status flag is set. Otherwise, 0 is returned.
>>
>> The fp_underflow subroutine returns 1 if a floating-point un-
>> derflow exception status flag is set. Otherwise, 0 is returned.
>>
>> The fp_inexact subroutine returns 1 if a floating-point inex-
>> act exception status flag is set. Otherwise, 0 is returned.
>>
>> The fp_any_xcp subroutine returns 1 if a floating-point in-
>> valid operation, divide by zero, overflow, underflow, or inexact
>> exception status flag is set. Otherwise, 0 is returned.
>>
>> The following routines are available for the AIX for RISC
>> System/6000 platform only:
>>
>> The fp_iop_snan subroutine returns 1 if a floating-point in-
>> valid operation exception status flag is set due to a signalling
>> NaN (NaNS). Otherwise, 0 is returned.
>>
>> The fp_iop_infsinf subroutine returns 1 if a floating-point
>> invalid operation exception status flag is set due to a INF-INF.
>> Otherwise, 0 is returned.
>>
>> The fp_iop_infdinf subroutine returns 1 if a floating-point
>> invalid operation exception status flag is set due to a INF/INF.
>> Otherwise, 0 is returned.
>>
>> The fp_iop_zrdzr subroutine returns 1 if a floating-point in-
>> valid operation exception status flag is set due to a 0.0/0.0.
>> Otherwise, 0 is returned.
>>
>> The fp_iop_infxzr subroutine returns 1 if a floating-point
>> invalid operation exception status flag is set due to a INF*0.0.
>> Otherwise, 0 is returned.
>>
>> The fp_iop_invcmp subroutine returns 1 if a floating-point
>> invalid operation exception status flag is set due to a compare
>> involving a NaN. Otherwise, 0 is returned.
>>
>> ...
========================================================================
Nelson H.F. Beebe
Center for Scientific Computing
Department of Mathematics
220 South Physics Building
University of Utah
Salt Lake City, UT 84112
Tel: (801) 581-5254
FAX: (801) 581-4148
Internet: beebeamath.utah.edu
========================================================================
More information about the Numeric-interest
mailing list