ISO/ IEC JTC1/SC22/WG14 N751

*                          Document Number:  WG14 N751/J11 97-114


                               C9X Revision Proposal
                               =====================

*      Title: LIA-1 Binding: Combined LIA-1 + IEC-559 annex
       Author: Fred J. Tydeman
       Author Affiliation: Tydeman Consulting
       Postal Address: 3711 Del Robles Dr., Austin, Texas, USA, 78727
       E-mail Address: tydeman@tybor.com
       Telephone Number: +1 (512) 255-8696
       Fax Number: +1 (512) 255-8696
       Sponsor: WG14
       Date: 1997-09-16
       Proposal Category:
          __ Editorial change/non-normative contribution
          __ Correction
          Y_ New feature
          __ Addition to obsolescent feature list
          __ Addition to Future Directions
          __ Other (please specify)  ______________________________
       Area of Standard Affected:
          __ Environment
          __ Language
          __ Preprocessor
          Y_ Library
             Y_ Macro/typedef/tag name
             Y_ Function
             __ Header
          __ Other (please specify)  ______________________________
       Prior Art: None known.
       Target Audience: Programmers writing programs that perform a
       significant amount of numeric processing.___________________
       Related Documents (if any):
        WG14/N758 C9X and LIA-1 informative annex,
        WG14/N756 LIA-1 Binding: Arithmetic exception => SIGFPE,
        WG14/N755 LIA-1 Binding: <fenv.h> to <stdmath.h>,
        WG14/N753 LIA-1 Binding: Rationale,
        WG14/N752 LIA-1 Binding: Optional parts annex,
        WG14/N750 LIA-1 Binding: LIA-1 annex,
        WG14/N749 LIA-1 Binding: <stdlia.h>,
        WG14/N748 LIA-1 Binding: Adding 'pole' from LIA-2,
        WG14/N747 IEC 559 Binding: Signaling NaNs,
        WG14/N528 C Binding for LIA-1,
        WG14/N488 LIA-2 (math library),
        WG14/N487 LIA-1 (arithmetic),
        WG14/N486 LIA Overview,
        WG14/N463 Impact of adding LIA-1,
        WG14/N461 C Binding of LIA-1
       Proposal Attached: _Y Yes __ No, but what's your interest?

       Abstract: This annex documents the binding required for an
       implementation to support both IEC 559 and LIA-1.

       Proposal: 

       Note: The '*' characters in the lefthand column are not part
       of the proposal (they are useful for emacs M-x outline mode)

       In the following, bold text, italic text,
       <TT>code sample</TT> are the conventions used to indicate
       text different from normal.

*      -- Add a new annex (call it I) with the following:

                                   Annex I
                                 (normative)

                    LIA-1 and IEC 559 compatible arithmetic

*      I.1 Introduction

       This annex supplements Annex F (IEC 559 binding) and Annex H
       (LIA-1 binding) to specify LIA-1 compliant IEC 559 real
       floating-point arithmetic.  An implementation supports this
       specification if and only if it defines the macros
       __STDC_IEC_559__ and __STDC_LIA_1__.

*      I.2 Extensions to other subclauses

**     7.x.1.2 Floating-point limits is extended with:

       -- boolean value (0 or 1) to indicate if IEC 559 tininess is
       detected "before rounding" (1) or "after rounding" (0)
       for all IEC 559 types,

           TINYNESS_BEFORE

       -- boolean value (0 or 1) to indicate if IEC 559
       loss-of-accuracy is detected as a denormalization loss (1)
       or as an inexact result (0) for all IEC 559 types,

           HAS_DENORM_LOSS

       [Note:  These names were chosen to match C++]

**     D.x.1.2 Floating-point limits is extended with:

           TINYNESS_BEFORE
           HAS_DENORM_LOSS

*      I.3 Signaling NaNs

       Support for signaling NaNs is not required. There is no
       binding between Standard C and signaling NaNs, hence there
       is no required method to denote any signaling NaNs.  This is
       a deviation from IEC 559 and from LIA-1.

*      I.4 Floating-Point Types

       The floating types float and double conform to
       both LIA-1 and IEC 559.

       The floating type long double shall conform to LIA-1
       and should conform to IEC 559.

**     I.4.1 Parameters

       The FLT_IEC_559 and DBL_IEC_559 parameters shall have the
       value 1 (true); LDBL_IEC_559 should have the value 1 (true).

       The FLT_SUBNORMAL and DBL_SUBNORMAL parameters shall have
       the value 1 (fully supported); LDBL_SUBNORMAL should have
       the value 1.

**     I.4.2 Operations

       The mapping of LIA-1 operations to C operations and the
       mapping of IEC 559 unique operations to C operations is
       extended with:

       The floating point operations are:

       =                 x == y.

       ?<>               x != y.

       >                 x > y.

       >=                x >= y.

       <                 x < y.

       <=                x <= y.

       ?                 isunordered(x, y).

       <>                No binding

       <=>               No binding

       ?>                No binding

       ?>=               No binding

       ?<                No binding

       ?<=               No binding

       ?=                No binding

       NOT(>)            No binding

       NOT(>=)           No binding

       NOT(<)            No binding

       NOT(<=)           No binding

       NOT(?)            !isunordered(x, y)

       NOT(<>)           No binding

       NOT(<=>)          No binding

       NOT(?>)           islessequal(x, y).

       NOT(?>=)          isless(x, y).

       NOT(?<)           isgreaterequal(x, y).

       NOT(?<=)          isgreater(x, y).

       NOT(?=)           islessgreater(x, y).

       where x and y are expressions of the same floating point
       type.

*      I.5 Floating point environment

**     - The fedisabletrap, feenabletrap, and fetesttrap functions,
       if provided, in <fenv.h> provide the optional IEC 559
       facility to test and alter the floating-point trap modes.

**     - If the implementation converts arithmetic exceptions that
       trap to SIGFPE, then the SIGFPE signal handlers (the user's
       and the implementation's default) are the handlers for the
       IEC 559 exceptions; otherwise, there are no trap handlers.

**     - The fegetprec and fesetprec functions in <fenv.h>, if
       provide, are the facility to select among the IEC 559
       precision modes.

*      I.6 IEC 559 Implementor's choice

**     - The macros FE_TRAP_INVALID, FE_TRAP_DIVBYZERO,
       FE_TRAP_OVERFLOW, FE_TRAP_UNDERFLOW, and FE_TRAP_INEXACT in
       <stdlia.h> if defined, or not, allow an application to
       determine if trapping is implemented for the respective
       floating-point trap.

**     - The macro TINYNESS_BEFORE in <stdlia.h> is the means used
       to determine if tininess is detected "before rounding" or
       "after rounding."

**     - The macro HAS_DENORM_LOSS in <stdlia.h> is the means used
       to determine if loss-of-accuracy is detected as a
       denormalization loss or as an inexact result.

**     - The macros FP2INT_OF_NAN, FP2INT_OF_INF, and
       FP2INT_OF_LARGE in <stdlia.h> are the means used to
       determine which exception is raised for conversion from any
       floating-point type to any signed integral type for
       respectively, NaNs, infinity, and large values that cannot
       be faithfully represented as an integer.

**     - The macros FE_FLTPREC, FE_DBLPREC, and FE_LDBLPREC in
       <fenv.h> if defined, or not, allow an application to
       determine if dynamic precision control is implemented.