Disable tests for strdup/strndup on __hpux__
[official-gcc.git] / gcc / ada / libgnat / a-nbnbre.ads
blobd342eebd6b64a59d8f115c834c7d23fbada1d61b
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- ADA.NUMERICS.BIG_NUMBERS.BIG_REALS --
6 -- --
7 -- S p e c --
8 -- --
9 -- This specification is derived from the Ada Reference Manual for use with --
10 -- GNAT. In accordance with the copyright of that document, you can freely --
11 -- copy and modify this specification, provided that if you redistribute a --
12 -- modified version, any changes that you have made are clearly indicated. --
13 -- --
14 ------------------------------------------------------------------------------
16 with Ada.Numerics.Big_Numbers.Big_Integers;
18 with Ada.Strings.Text_Buffers; use Ada.Strings.Text_Buffers;
20 package Ada.Numerics.Big_Numbers.Big_Reals with
21 Preelaborate,
22 Always_Terminates
25 type Big_Real is private with
26 Real_Literal => From_Universal_Image,
27 Put_Image => Put_Image;
29 function Is_Valid (Arg : Big_Real) return Boolean
30 with
31 Convention => Intrinsic,
32 Global => null;
34 subtype Valid_Big_Real is Big_Real
35 with Dynamic_Predicate => Is_Valid (Valid_Big_Real),
36 Predicate_Failure => raise Program_Error;
38 function "/"
39 (Num, Den : Big_Integers.Valid_Big_Integer) return Valid_Big_Real
40 with Global => null;
41 -- with Pre => (Big_Integers."/=" (Den, Big_Integers.To_Big_Integer (0))
42 -- or else Constraint_Error);
44 function Numerator
45 (Arg : Valid_Big_Real) return Big_Integers.Valid_Big_Integer
46 with Global => null;
48 function Denominator (Arg : Valid_Big_Real) return Big_Integers.Big_Positive
49 with
50 Post =>
51 (if Arg = To_Real (0)
52 then Big_Integers."=" (Denominator'Result,
53 Big_Integers.To_Big_Integer (1))
54 else Big_Integers."="
55 (Big_Integers.Greatest_Common_Divisor
56 (Numerator (Arg), Denominator'Result),
57 Big_Integers.To_Big_Integer (1))),
58 Global => null;
60 function To_Big_Real
61 (Arg : Big_Integers.Big_Integer)
62 return Valid_Big_Real is (Arg / Big_Integers.To_Big_Integer (1))
63 with Global => null;
65 function To_Real (Arg : Integer) return Valid_Big_Real is
66 (Big_Integers.To_Big_Integer (Arg) / Big_Integers.To_Big_Integer (1))
67 with Global => null;
69 function "=" (L, R : Valid_Big_Real) return Boolean with Global => null;
71 function "<" (L, R : Valid_Big_Real) return Boolean with Global => null;
73 function "<=" (L, R : Valid_Big_Real) return Boolean with Global => null;
75 function ">" (L, R : Valid_Big_Real) return Boolean with Global => null;
77 function ">=" (L, R : Valid_Big_Real) return Boolean with Global => null;
79 function In_Range (Arg, Low, High : Big_Real) return Boolean is
80 (Low <= Arg and then Arg <= High)
81 with Global => null;
83 generic
84 type Num is digits <>;
85 package Float_Conversions is
87 function To_Big_Real (Arg : Num) return Valid_Big_Real
88 with Global => null;
90 function From_Big_Real (Arg : Big_Real) return Num
91 with
92 Pre => In_Range (Arg,
93 Low => To_Big_Real (Num'First),
94 High => To_Big_Real (Num'Last))
95 or else (raise Constraint_Error),
96 Global => null;
98 end Float_Conversions;
100 generic
101 type Num is delta <>;
102 package Fixed_Conversions is
104 function To_Big_Real (Arg : Num) return Valid_Big_Real
105 with Global => null;
107 function From_Big_Real (Arg : Big_Real) return Num
108 with
109 Pre => In_Range (Arg,
110 Low => To_Big_Real (Num'First),
111 High => To_Big_Real (Num'Last))
112 or else (raise Constraint_Error),
113 Global => null;
115 end Fixed_Conversions;
117 function To_String (Arg : Valid_Big_Real;
118 Fore : Field := 2;
119 Aft : Field := 3;
120 Exp : Field := 0) return String
121 with
122 Post => To_String'Result'First = 1,
123 Global => null;
125 function From_String (Arg : String) return Valid_Big_Real
126 with Global => null;
128 function From_Universal_Image (Arg : String) return Valid_Big_Real
129 renames From_String;
130 function From_Universal_Image (Num, Den : String) return Valid_Big_Real is
131 (Big_Integers.From_Universal_Image (Num) /
132 Big_Integers.From_Universal_Image (Den))
133 with Global => null;
135 function To_Quotient_String (Arg : Big_Real) return String is
136 (Big_Integers.To_String (Numerator (Arg)) & " / "
137 & Big_Integers.To_String (Denominator (Arg)))
138 with Global => null;
140 function From_Quotient_String (Arg : String) return Valid_Big_Real
141 with Global => null;
143 procedure Put_Image (S : in out Root_Buffer_Type'Class; V : Big_Real);
145 function "+" (L : Valid_Big_Real) return Valid_Big_Real
146 with Global => null;
148 function "-" (L : Valid_Big_Real) return Valid_Big_Real
149 with Global => null;
151 function "abs" (L : Valid_Big_Real) return Valid_Big_Real
152 with Global => null;
154 function "+" (L, R : Valid_Big_Real) return Valid_Big_Real
155 with Global => null;
157 function "-" (L, R : Valid_Big_Real) return Valid_Big_Real
158 with Global => null;
160 function "*" (L, R : Valid_Big_Real) return Valid_Big_Real
161 with Global => null;
163 function "/" (L, R : Valid_Big_Real) return Valid_Big_Real
164 with Global => null;
166 function "**" (L : Valid_Big_Real; R : Integer) return Valid_Big_Real
167 with Global => null;
169 function Min (L, R : Valid_Big_Real) return Valid_Big_Real
170 with Global => null;
172 function Max (L, R : Valid_Big_Real) return Valid_Big_Real
173 with Global => null;
175 private
177 type Big_Real is record
178 Num, Den : Big_Integers.Big_Integer;
179 end record;
181 end Ada.Numerics.Big_Numbers.Big_Reals;