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