1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 -- This package provides for compile-time evaluation of static calls to the
30 -- floating-point attribute functions. It is the compile-time equivalent of
31 -- the System.Fat_Gen runtime package. The coding is quite similar, as are
32 -- the subprogram specs, except that the type is passed as an explicit
33 -- first parameter (and used via ttypes, to obtain the necessary information
34 -- about the characteristics of the type for computing the results.
36 with Types
; use Types
;
37 with Uintp
; use Uintp
;
38 with Urealp
; use Urealp
;
43 -- The compile time representation of universal integer
46 -- The compile time representation of floating-point values
48 subtype R
is Entity_Id
;
49 -- The compile time representation of the floating-point root type
51 type Rounding_Mode
is (Floor
, Ceiling
, Round
, Round_Even
);
52 for Rounding_Mode
use (0, 1, 2, 3);
53 -- Used to indicate rounding mode for Machine attribute
54 -- Note that C code in gigi knows that Round_Even is 3
56 Rounding_Was_Biased
: Boolean;
57 -- Set if last use of Machine rounded a halfway case away from zero
59 function Adjacent
(RT
: R
; X
, Towards
: T
) return T
;
61 function Ceiling
(RT
: R
; X
: T
) return T
;
63 function Compose
(RT
: R
; Fraction
: T
; Exponent
: UI
) return T
;
65 function Copy_Sign
(RT
: R
; Value
, Sign
: T
) return T
;
67 function Exponent
(RT
: R
; X
: T
) return UI
;
69 function Floor
(RT
: R
; X
: T
) return T
;
71 function Fraction
(RT
: R
; X
: T
) return T
;
73 function Leading_Part
(RT
: R
; X
: T
; Radix_Digits
: UI
) return T
;
75 function Machine
(RT
: R
; X
: T
; Mode
: Rounding_Mode
) return T
;
77 function Model
(RT
: R
; X
: T
) return T
;
79 function Pred
(RT
: R
; X
: T
) return T
;
81 function Remainder
(RT
: R
; X
, Y
: T
) return T
;
83 function Rounding
(RT
: R
; X
: T
) return T
;
85 function Scaling
(RT
: R
; X
: T
; Adjustment
: UI
) return T
;
87 function Succ
(RT
: R
; X
: T
) return T
;
89 function Truncation
(RT
: R
; X
: T
) return T
;
91 function Unbiased_Rounding
(RT
: R
; X
: T
) return T
;