Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Numbers/multprec_integer_numbers.ads, Revision 1.1.1.1
1.1 maekawa 1: with Multprec_Natural_Numbers; use Multprec_Natural_Numbers;
2:
3: package Multprec_Integer_Numbers is
4:
5: -- DESCRIPTION :
6: -- This package allows to manipulate integer numbers of arbitrary length.
7: -- The operations are such that this is a faithful representation of the
8: -- integers as an Euclidean domain.
9:
10: -- DATA STRUCTURES :
11:
12: type Integer_Number is private;
13:
14: -- CREATORS :
15:
16: function Create ( n : Natural_Number ) return Integer_Number;
17: function Create ( n : Array_of_Naturals ) return Integer_Number;
18: function Create ( i : integer ) return Integer_Number;
19:
20: -- DESCRIPTION :
21: -- Returns the representation as a natural number.
22:
23: function Convert ( n : Natural_Number ) return Integer_Number;
24:
25: -- DESCRIPTION :
26: -- This operation has the same effect as create, except that
27: -- n and i := Convert(n), share the same number: if n changes
28: -- after conversion, i will change as well, and vice versa.
29: -- This operation can be useful for integer/natural arithmetic.
30:
31: function Create ( i : Integer_Number ) return integer;
32:
33: -- DESCRIPTION :
34: -- Returns the representation of i as a standard integer.
35:
36: -- REQUIRED : i < Natural_Numbers.Basis.
37:
38: -- SELECTORS :
39:
40: function Empty ( i : Integer_Number ) return boolean;
41:
42: -- DESCRIPTION :
43: -- Returns true if the number has not been created yet, or when it has
44: -- been destroyed by the operation Clear; otherwise false is returned.
45: -- An empty number is considered as zero.
46:
47: function Size ( i : Integer_Number ) return natural;
48:
49: -- DESCRIPTION :
50: -- Returns the index of the last entry in the coefficient representation.
51:
52: function Coefficient ( i : Integer_Number; k : natural ) return natural;
53:
54: -- DESCRIPTION :
55: -- Returns the kth component in the coefficient representation of i.
56:
57: function Coefficients ( i : Integer_Number ) return Array_of_Naturals;
58:
59: -- DESCRIPTION :
60: -- Returns the coefficient representation of the unsigned integer.
61:
62: function Decimal_Places ( i : Integer_Number ) return natural;
63:
64: -- DESCRIPTION :
65: -- Returns the number of decimal places of i.
66: -- The number of decimal places of 0 is 0.
67:
68: function Positive ( i : Integer_Number ) return boolean;
69: function Negative ( i : Integer_Number ) return boolean;
70:
71: -- DESCRIPTION :
72: -- If i > 0, then Positive(i) and not Negative(i).
73: -- If i < 0, then not Positive(i) and Negative(i).
74: -- For i = 0, sign switching by Min(i) can give either +0 or -0.
75:
76: function Sign ( i : Integer_Number ) return integer;
77:
78: -- DESCRIPTION :
79: -- Returns +1,-1, or 0, depending whether i > 0, i < 0, or i = 0.
80:
81: function Unsigned ( i : Integer_Number ) return Natural_Number;
82:
83: -- DESCRIPTION :
84: -- Returns the unsigned integer number.
85: -- Note that this is a pointer with data sharing!
86:
87: -- COMPARISON AND COPYING :
88:
89: function Equal ( i1 : Integer_Number; i2 : integer ) return boolean;
90: function Equal ( i1,i2 : Integer_Number ) return boolean;
91:
92: -- DESCRIPTION :
93: -- Returns true when both numbers i1 and i2 are equal, false otherwise.
94:
95: function "<" ( i1 : Integer_Number; i2 : integer ) return boolean;
96: function "<" ( i1 : integer; i2 : Integer_Number ) return boolean;
97: function "<" ( i1,i2 : Integer_Number ) return boolean;
98:
99: -- DESCRIPTION :
100: -- Returns true if i1 < i2, false otherwise.
101:
102: function ">" ( i1 : Integer_Number; i2 : integer ) return boolean;
103: function ">" ( i1 : integer; i2 : Integer_Number ) return boolean;
104: function ">" ( i1,i2 : Integer_Number ) return boolean;
105:
106: -- DESCRIPTION :
107: -- Returns true if i1 > i2, false otherwise.
108:
109: procedure Copy ( i1 : in integer; i2 : in out Integer_Number );
110: procedure Copy ( i1 : in Integer_Number; i2 : in out Integer_Number );
111:
112: -- DESCRIPTION :
113: -- Clears i2 and makes a copy of i1 to be equal to i2.
114: -- Note that i2 := i1 leads to data sharing.
115:
116: -- ARITHMETIC OPERATIONS as functions (no data sharing) :
117:
118: function "+" ( i1 : Integer_Number; i2 : integer ) return Integer_Number;
119: function "+" ( i1 : integer; i2 : Integer_Number ) return Integer_Number;
120: function "+" ( i1,i2 : Integer_Number ) return Integer_Number;
121:
122: function "+" ( i : Integer_Number ) return Integer_Number; -- copies i
123: function "-" ( i : Integer_Number ) return Integer_Number;
124:
125: function "-" ( i1 : Integer_Number; i2 : integer ) return Integer_Number;
126: function "-" ( i1 : integer; i2 : Integer_Number ) return Integer_Number;
127: function "-" ( i1,i2 : Integer_Number ) return Integer_Number;
128:
129: function "*" ( i1 : Integer_Number; i2 : integer ) return Integer_Number;
130: function "*" ( i1 : integer; i2 : Integer_Number ) return Integer_Number;
131: function "*" ( i1,i2 : Integer_Number ) return Integer_Number;
132:
133: function "**" ( i : Integer_Number; n : natural ) return Integer_Number;
134: function "**" ( i : integer; n : Natural_Number ) return Integer_Number;
135: function "**" ( i : Integer_Number; n : Natural_Number )
136: return Integer_Number;
137:
138: function "/" ( i1 : Integer_Number; i2 : integer ) return Integer_Number;
139: function "/" ( i1 : integer; i2 : Integer_Number ) return integer;
140: function "/" ( i1,i2 : Integer_Number ) return Integer_Number;
141:
142: function Rmd ( i1 : Integer_Number; i2 : integer ) return integer;
143: function Rmd ( i1 : integer; i2 : Integer_Number ) return integer;
144: function Rmd ( i1,i2 : Integer_Number ) return Integer_Number;
145:
146: -- ARITHMETIC OPERATIONS as procedures for memory management :
147:
148: procedure Add ( i1 : in out Integer_Number; i2 : in integer ); -- "+"
149: procedure Add ( i1 : in out Integer_Number; i2 : in Integer_Number );
150:
151: procedure Min ( i : in out Integer_Number );
152:
153: procedure Sub ( i1 : in out Integer_Number; i2 : in integer ); -- "-"
154: procedure Sub ( i1 : in out Integer_Number; i2 : in Integer_Number );
155:
156: procedure Mul ( i1 : in out Integer_Number; i2 : in integer ); -- "*"
157: procedure Mul ( i1 : in out Integer_Number; i2 : in Integer_Number );
158:
159: procedure Rmd ( i1 : in out Integer_Number; i2 : in integer );
160: procedure Rmd ( i1 : in out Integer_Number; i2 : in Integer_Number );
161:
162: procedure Div ( i1 : in out Integer_Number; i2 : in integer ); -- "/"
163: procedure Div ( i1 : in out Integer_Number; i2 : in Integer_Number );
164:
165: procedure Div ( i1 : in Integer_Number; i2 : in integer; -- i1 = i2*q+r
166: q : out Integer_Number; r : out integer );
167: procedure Div ( i1 : in out Integer_Number; i2 : in integer;
168: r : out integer );
169: procedure Div ( i1,i2 : in Integer_Number; q,r : out Integer_Number );
170: procedure Div ( i1 : in out Integer_Number; i2 : in Integer_Number;
171: r : out Integer_Number );
172:
173: -- DESTRUCTOR :
174:
175: procedure Clear ( i : in out Integer_Number );
176:
177: -- DESCRIPTION :
178: -- Deallocation of the memory space. Empty(i) is true on return.
179:
180: private
181:
182: type Integer_Number_Rep;
183: type Integer_Number is access Integer_Number_Rep;
184:
185: end Multprec_Integer_Numbers;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>