--- ais/ai-00315.txt 2004/01/23 04:59:27 1.4 +++ ais/ai-00315.txt 2004/03/02 04:45:00 1.5 @@ -1,4 +1,4 @@ -!standard A.5.3 (00) 03-11-04 AI95-00315/01 +!standard A.5.3 (00) 04-02-27 AI95-00315/02 !class amendment 02-09-30 !status work item 03-11-04 !status received 02-09-26 @@ -8,18 +8,18 @@ !summary -A new mode, named IEEE mode, is defined to provide support for IEC 559:1989 +A new mode, named IEC 559 mode, is defined to provide support for IEC 559:1989 !problem !proposal -The IEEE mode is a mode "stricter than strict". That is, all the requirements +The IEC 559 mode is a mode "stricter than strict". That is, all the requirements for strict mode apply, plus some others. It is unspecified which mode is the default, if the three modes actually differ, and how the user selects a particular mode. -In the IEEE mode, Interfaces.IEEE_Float_32 must be present. Other types in +In the IEC 559 mode, Interfaces.IEEE_Float_32 must be present. Other types in Interfaces, e.g. IEEE_Float_64, must be present if *fully* supported by the hardware. By *fully* supported, we mean that all the requirements of IEC 559:1989, with the possible exception of those pertaining to binary <-> decimal @@ -104,25 +104,49 @@ returns True if X and Y are unordered. -All these attributes are static if their prefix and arguments (if any) are. +The attributes Is_NaN, Finite and Unordered are static if their prefix and +arguments are. + Implementation Advice + +The attribute X'Valid should return True if and only if S'Is_Nan (X) returns +False. In particular, an infinity should be a valid value. + + Bounded (Run-Time) Errors + +Any usage of a signalling NaN, other than passing it to one of the attributes +Is_NaN, Finite, Unordered or Valid, is a bounded error. The possible +consequences are that Program_Error is raised, or Constraint_Error is raised, or +the signalling NaN behaves as a quiet NaN. + +The evaluation of a language-defined relational operator is a bounded error if +one of the operands is a quiet NaN. The possible consequences are that +Program_Error is raised, or the result of the evalution is False, or the result +of the evaluation is True. + +The conversion of a quiet NaN to a numeric type with a different underlying +representation is a bounded error. The possible consequences are that +Program_Error is raised, or the result of the conversion is a quiet NaN (if the +target type supports such a value). + + The following predefined package is added: -package Ada.Numerics.IEEE is +package Ada.Numerics.IEC_559 is - type Rounding_Mode is (Round_To_Nearest, - Round_Towards_Zero, - Round_Up, - Round_Down); - procedure Set_Rounding_Mode (R : Rounding_Mode); - function Get_Rounding_Mode return Rounding_Mode; + type Rounding_Modes is (Round_To_Nearest, + Round_Towards_Zero, + Round_Up, + Round_Down); + procedure Set_Rounding_Mode (R : Rounding_Modes); + function Rounding_Mode return Rounding_Modes; type Format is (Single, Single_Extended, Double, Double_Extended); procedure Set_Rounding_Precision (F : Format); - function Get_Rounding_Precision return Format; + function Rounding_Precision return Format; -- The following is called "exception" by IEC 559:1989... type Event is (Invalid_Operation, @@ -131,11 +155,11 @@ Underflow, Inexact); procedure Set_Flag (E : Event; To : Boolean); - function Get_Flag (E : Event) return Boolean; + function Flag (E : Event) return Boolean; - type Flags is array (Event) of Boolean; - procedure Set_Flags (F : Flags); - function Get_Flags return Flags; + type Events is array (Event) of Boolean; + procedure Set_Flags (E : Events); + function Flags return Events; -- Is this the right level of granularity? type Operation is (Add, @@ -155,18 +179,18 @@ generic type T is digits <>; package Traps is - type Handler is access function (E : Event; - Op : Operation; - Fmt : Format; - Result : T; - Arg1, Arg2 : T) return T; - procedure Enable_Trap (H : Handler; E : Event); + type Trap_Handler is access function (E : Event; + Op : Operation; + Fmt : Format; + Result : T; + Arg1, Arg2 : T) return T; + procedure Enable_Trap (H : Trap_Handler; E : Event); procedure Disable_Trap (E : Event); function Trap_Is_Enabled (E : Event) return Boolean; - function Get_Handler (E : Event) return Handler; + function Handler (E : Event) return Trap_Handler; end Traps; -end Ada.Numerics.IEEE; +end Ada.Numerics.IEC_559; This package operates on global, system-wide state that is modified or used by a variety of floating-point operations. Only basic facilities are provided @@ -206,7 +230,7 @@ and is unspecified for Invalid_Operation. The Ada default is in effect when a partition starts. -The correspondence between Ada operations and IEEE operations is unspecified. +The correspondence between Ada operations and IEC 559 operations is unspecified. Therefore, relying on the operation passed to the handler may be unreliable, unless code statements are used. @@ -244,7 +268,9 @@ with all the properties of IEEE 754. DK 98 -Kahan, W; Darcy, Joseph D.: How Java's Floating-Point Hurts Everyone Everywhere. http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf, June 18, 1998. (visited: 2000.Nov.04 ) +Kahan, W; Darcy, Joseph D.: How Java's Floating-Point Hurts Everyone Everywhere. +http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf, June 18, 1998. (visited: +2000.Nov.04 ) Win 2002 Winkler, Jrgen F. H.: A safe variant of the unsafe integer arithmetic of Java.

Questions? Ask the ACAA Technical Agent