Mercurial > projects > decimal
annotate src/decimal/math.d @ 4:b37c218c1442
Initial development of BCD integers
author | Paul (paul.d.anderson@comcast.net) |
---|---|
date | Thu, 18 Mar 2010 18:10:25 -0700 |
parents | a984d3056cc4 |
children |
rev | line source |
---|---|
1
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
1 /** |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
2 * A D programming language implementation of the |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
3 * General Decimal Arithmetic Specification, |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
4 * Version 1.70, (25 March 2009). |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
5 * |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
6 * by Paul D. Anderson |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
7 * |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
8 * Boost Software License - Version 1.0 - August 17th, 2003 |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
9 * |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
10 * Permission is hereby granted, free of charge, to any person or organization |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
11 * obtaining a copy of the software and accompanying documentation covered by |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
12 * this license (the "Software") to use, reproduce, display, distribute, |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
13 * execute, and transmit the Software, and to prepare derivative works of the |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
14 * Software, and to permit third-parties to whom the Software is furnished to |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
15 * do so, all subject to the following: |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
16 * |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
17 * The copyright notices in the Software and this entire statement, including |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
18 * the above license grant, this restriction and the following disclaimer, |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
19 * must be included in all copies of the Software, in whole or in part, and |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
20 * all derivative works of the Software, unless such copies or derivative |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
21 * works are solely in the form of machine-executable object code generated by |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
22 * a source language processor. |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
23 * |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
26 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
27 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
28 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
29 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
30 * DEALINGS IN THE SOFTWARE. |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
31 **/ |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
32 |
a984d3056cc4
Incorporated Boost License
Paul (paul.d.anderson@comcast.net)
parents:
0
diff
changeset
|
33 module decimal.math; |
0 | 34 |
35 import decimal.decimal; | |
36 import decimal.context; | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
37 //import std.math; |
0 | 38 |
39 public: | |
40 | |
41 //-------------------------------- | |
42 // | |
43 // CONSTANTS | |
44 // | |
45 //-------------------------------- | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
46 |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
47 /+ public Decimal HALF; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
48 public Decimal ONE = Decimal(1); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
49 public Decimal ZERO = Decimal(0); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
50 |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
51 static { |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
52 HALF = Decimal("0.5"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
53 }+/ |
0 | 54 |
55 /** | |
56 * Returns the value of e to the default precision. | |
57 */ | |
58 Decimal e() { | |
59 Decimal result; | |
60 return result; | |
61 } | |
62 | |
63 /** | |
64 * Returns the value of e to the specified precision. | |
65 */ | |
66 Decimal e(uint precision) { | |
67 Decimal result; | |
68 return result; | |
69 } | |
70 | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
71 /+ |
0 | 72 /** |
73 * Returns the value of pi to the default precision. | |
74 */ | |
75 Decimal pi() { | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
76 Decimal ONE = Decimal(1); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
77 writeln("1 = ", ONE); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
78 Decimal TWO = Decimal(2); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
79 writeln("2 = ", TWO); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
80 Decimal HALF = Decimal(0.5); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
81 writeln("0.5 = ", HALF); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
82 Decimal x = sqrt(TWO); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
83 writeln("x = ", x); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
84 Decimal y = sqrt(x); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
85 writeln("y = ", y); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
86 Decimal p = TWO + x; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
87 writeln("p = ", p); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
88 x = y; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
89 int i = 0; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
90 while (true) { |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
91 writeln("i = ", i); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
92 x = HALF * (x + ONE/x); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
93 writeln("step 1"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
94 Decimal np = p * ((x + ONE)/(y + ONE)); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
95 writeln("step 2"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
96 writeln("np = ", np); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
97 if (p == np) return p; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
98 writeln("step 3"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
99 p = np; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
100 writeln("step 4"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
101 x = sqrt(x); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
102 writeln("step 5"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
103 // writeln("x = ", x); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
104 Decimal oox = ONE/x; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
105 // writeln("ONE/x = ", oox); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
106 // writeln ("x + ONE/x = ", x + oox); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
107 // Decimal t1 = oox + x; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
108 // writeln("t1 = ", t1); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
109 // Decimal t1 = x + oox; // ONE + oox; //x + x; // + ONE/x; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
110 writeln("step 6"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
111 // Decimal t2 = (y * x) + ONE; ///x; //ONE / (y + ONE); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
112 // y = ONE/x + y * x; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
113 writeln("step 7"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
114 y = (ONE/x + y * x) / (y + ONE); //t1 / t2; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
115 writeln("step 8"); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
116 i++; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
117 // break; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
118 } |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
119 return p; |
0 | 120 } |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
121 |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
122 unittest { |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
123 write("pi...."); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
124 writeln("pi = ", pi()); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
125 } |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
126 +/ |
0 | 127 /** |
128 * Returns the value of pi to the specified precision. | |
129 */ | |
130 Decimal pi(uint precision) {; | |
131 Decimal result; | |
132 return result; | |
133 } | |
134 | |
135 /** | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
136 * Returns the square root of the argument to the current precision. |
0 | 137 */ |
138 Decimal sqrt(Decimal arg) { | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
139 return sqrt(arg, context.precision); |
0 | 140 } |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
141 |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
142 |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
143 unittest { |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
144 write("sqrt....."); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
145 Decimal dcm = Decimal(4); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
146 assert(sqrt(dcm) == Decimal(2)); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
147 writeln("sqrt(2) = ", sqrt(Decimal(2))); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
148 } |
0 | 149 |
150 /** | |
151 * Returns the square root of the argument to the specified precision. | |
152 */ | |
153 Decimal sqrt(Decimal arg, uint precision) { | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
154 pushContext(); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
155 context.precision = precision + 2; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
156 Decimal HALF = Decimal(0.5); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
157 Decimal ONE = Decimal(1); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
158 Decimal x = HALF * (arg + ONE); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
159 Decimal xp; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
160 while(true){ |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
161 xp = x; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
162 x = HALF * (x + arg/x); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
163 if (x == xp) break; |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
164 } |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
165 popContext(); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
166 round(xp); |
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
167 return xp; |
0 | 168 } |
169 | |
170 //-------------------------------- | |
171 // | |
172 // EXPONENTIAL AND LOGARITHMIC FUNCTIONS | |
173 // | |
174 //-------------------------------- | |
175 | |
176 /** | |
177 * Decimal version of std.math function. | |
178 * Required by General Decimal Arithmetic Specification | |
179 * | |
180 */ | |
181 Decimal exp(Decimal arg) { | |
182 Decimal result; | |
183 return result; | |
184 } | |
185 | |
186 /** | |
187 * Decimal version of std.math function. | |
188 * 2^x | |
189 */ | |
190 Decimal exp2(Decimal arg) { | |
191 Decimal result; | |
192 return result; | |
193 } | |
194 | |
195 /** | |
196 * Decimal version of std.math function. | |
197 * exp(x) - 1 | |
198 */ | |
199 Decimal expm1(Decimal arg) { | |
200 Decimal result; | |
201 return result; | |
202 } | |
203 | |
204 /** | |
205 * Decimal version of std.math function. | |
206 * Required by General Decimal Arithmetic Specification | |
207 * | |
208 */ | |
209 Decimal log(Decimal arg) { | |
210 Decimal result; | |
211 return result; | |
212 } | |
213 | |
214 /** | |
215 * Decimal version of std.math function. | |
216 * log(1 + x) | |
217 */ | |
218 Decimal log1p(Decimal arg) { | |
219 Decimal result; | |
220 return result; | |
221 } | |
222 | |
223 /** | |
224 * Decimal version of std.math function. | |
225 * Required by General Decimal Arithmetic Specification | |
226 * | |
227 */ | |
228 Decimal log10(Decimal arg) { | |
229 Decimal result; | |
230 return result; | |
231 } | |
232 | |
233 /** | |
234 * Decimal version of std.math function. | |
235 * Required by General Decimal Arithmetic Specification | |
236 * | |
237 */ | |
238 Decimal log2(Decimal arg) { | |
239 Decimal result; | |
240 return result; | |
241 } | |
242 | |
243 /** | |
244 * Decimal version of std.math function. | |
245 * Required by General Decimal Arithmetic Specification | |
246 * | |
247 */ | |
248 Decimal pow(Decimal op1, Decimal op2) { | |
249 Decimal result; | |
250 return result; | |
251 } | |
252 | |
253 //-------------------------------- | |
254 // | |
255 // TRIGONOMETRIC FUNCTIONS | |
256 // | |
257 //-------------------------------- | |
258 | |
259 /** | |
260 * Decimal version of std.math function. | |
261 * | |
262 */ | |
263 Decimal sin(Decimal arg) { | |
264 Decimal result; | |
265 return result; | |
266 } | |
267 | |
268 /** | |
269 * Decimal version of std.math function. | |
270 * | |
271 */ | |
272 Decimal cos(Decimal arg) { | |
273 Decimal result; | |
274 return result; | |
275 } | |
276 | |
277 /** | |
278 * Replaces std.math function expi | |
279 * | |
280 */ | |
281 Decimal[] sincos(Decimal arg) { | |
282 Decimal[] result; | |
283 return result; | |
284 } | |
285 | |
286 /** | |
287 * Decimal version of std.math function. | |
288 * | |
289 */ | |
290 Decimal tan(Decimal arg) { | |
291 Decimal result; | |
292 return result; | |
293 } | |
294 | |
295 /** | |
296 * Decimal version of std.math function. | |
297 * | |
298 */ | |
299 Decimal asin(Decimal arg) { | |
300 Decimal result; | |
301 return result; | |
302 } | |
303 | |
304 /** | |
305 * Decimal version of std.math function. | |
306 * | |
307 */ | |
308 Decimal acos(Decimal arg) { | |
309 Decimal result; | |
310 return result; | |
311 } | |
312 | |
313 /** | |
314 * Decimal version of std.math function. | |
315 * | |
316 */ | |
317 Decimal atan(Decimal arg) { | |
318 Decimal result; | |
319 return result; | |
320 } | |
321 | |
322 /** | |
323 * Decimal version of std.math function. | |
324 * | |
325 */ | |
326 Decimal atan2(Decimal y, Decimal x) { | |
327 Decimal result; | |
328 return result; | |
329 } | |
330 | |
331 //-------------------------------- | |
332 // | |
333 // HYPERBOLIC TRIGONOMETRIC FUNCTIONS | |
334 // | |
335 //-------------------------------- | |
336 | |
337 /** | |
338 * Decimal version of std.math function. | |
339 * | |
340 */ | |
341 Decimal sinh(Decimal arg) { | |
342 Decimal result; | |
343 return result; | |
344 } | |
345 | |
346 /** | |
347 * Decimal version of std.math function. | |
348 * | |
349 */ | |
350 Decimal cosh(Decimal arg) { | |
351 Decimal result; | |
352 return result; | |
353 } | |
354 | |
355 /** | |
356 * Decimal version of std.math function. | |
357 * | |
358 */ | |
359 Decimal tanh(Decimal arg) { | |
360 Decimal result; | |
361 return result; | |
362 } | |
363 | |
364 /** | |
365 * Decimal version of std.math function. | |
366 * | |
367 */ | |
368 Decimal asinh(Decimal arg) { | |
369 Decimal result; | |
370 return result; | |
371 } | |
372 | |
373 /** | |
374 * Decimal version of std.math function. | |
375 * | |
376 */ | |
377 Decimal acosh(Decimal arg) { | |
378 Decimal result; | |
379 return result; | |
380 } | |
381 | |
382 /** | |
383 * Decimal version of std.math function. | |
384 * | |
385 */ | |
386 Decimal atanh(Decimal arg) { | |
387 Decimal result; | |
388 return result; | |
389 } | |
390 | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
391 /+ //-------------------------------- |
0 | 392 // |
393 // General Decimal Arithmetic Specification Functions | |
394 // | |
395 //-------------------------------- | |
396 | |
397 /** | |
398 * part of spec | |
399 * | |
400 * TODO: implement | |
401 */ | |
402 Decimal compare(Decimal op1, Decimal op2) { | |
403 Decimal result; | |
404 return result; | |
405 } | |
406 | |
407 /** | |
408 * part of spec | |
409 * | |
410 * TODO: implement | |
411 */ | |
412 Decimal compareSignal(Decimal op1, Decimal op2) { | |
413 Decimal result; | |
414 return result; | |
415 } | |
416 | |
417 /** | |
418 * part of spec | |
419 * | |
420 * TODO: implement | |
421 */ | |
422 Decimal compareTotal(Decimal op1, Decimal op2) { | |
423 Decimal result; | |
424 return result; | |
425 } | |
426 | |
427 /** | |
428 * part of spec | |
429 * | |
430 * TODO: implement | |
431 */ | |
432 Decimal divideInteger(Decimal op1, Decimal op2) { | |
433 Decimal result; | |
434 return result; | |
435 } | |
436 | |
437 /** | |
438 * part of spec | |
439 * | |
440 * TODO: implement | |
441 */ | |
442 Decimal fma(Decimal op1, Decimal op2, Decimal op3) { | |
443 Decimal result; | |
444 return result; | |
445 } | |
446 | |
447 /** | |
448 * part of spec | |
449 * | |
450 * TODO: implement | |
451 */ | |
452 Decimal ln(Decimal op1) { | |
453 Decimal result; | |
454 return result; | |
455 } | |
456 | |
457 /** | |
458 * part of spec | |
459 * | |
460 * TODO: implement | |
461 */ | |
462 Decimal log10(Decimal op1) { | |
463 Decimal result; | |
464 return result; | |
465 } | |
466 | |
467 /** | |
468 * part of spec | |
469 * | |
470 * TODO: implement | |
471 */ | |
472 Decimal max(Decimal op1, Decimal op2) { | |
473 Decimal result; | |
474 return result; | |
475 } | |
476 | |
477 /** | |
478 * part of spec | |
479 * | |
480 * TODO: implement | |
481 */ | |
482 Decimal maxMagnitude(Decimal op1, Decimal op2) { | |
483 Decimal result; | |
484 return result; | |
485 } | |
486 | |
487 /** | |
488 * part of spec | |
489 * | |
490 * TODO: implement | |
491 */ | |
492 Decimal min(Decimal op1, Decimal op2) { | |
493 Decimal result; | |
494 return result; | |
495 } | |
496 | |
497 /** | |
498 * part of spec | |
499 * | |
500 * TODO: implement | |
501 */ | |
502 Decimal minMagnitude(Decimal op1, Decimal op2) { | |
503 Decimal result; | |
504 return result; | |
505 } | |
506 | |
507 /** | |
508 * part of spec | |
509 * | |
510 * TODO: implement | |
511 */ | |
512 Decimal nextMinus(Decimal op1) { | |
513 Decimal result; | |
514 return result; | |
515 } | |
516 | |
517 /** | |
518 * part of spec | |
519 * | |
520 * TODO: implement | |
521 */ | |
522 Decimal nextPlus(Decimal op1) { | |
523 Decimal result; | |
524 return result; | |
525 } | |
526 | |
527 /** | |
528 * part of spec | |
529 * | |
530 * TODO: implement | |
531 */ | |
532 Decimal nextToward(Decimal op1, Decimal op2) { | |
533 Decimal result; | |
534 return result; | |
535 } | |
536 | |
537 /** | |
538 * part of spec | |
539 * | |
540 * TODO: implement | |
541 */ | |
542 Decimal power(Decimal op1, Decimal op2) { | |
543 Decimal result; | |
544 return result; | |
545 } | |
546 | |
547 /** | |
548 * part of spec | |
549 * | |
550 * TODO: implement | |
551 */ | |
552 Decimal remainder(Decimal op1, Decimal op2) { | |
553 Decimal result; | |
554 return result; | |
555 } | |
556 | |
557 /** | |
558 * part of spec | |
559 * | |
560 * TODO: implement | |
561 */ | |
562 Decimal remainderNear(Decimal op1, Decimal op2) { | |
563 Decimal result; | |
564 return result; | |
565 } | |
566 | |
567 /** | |
568 * part of spec | |
569 * | |
570 * NOTE: performs both round-to-integral-exact and | |
571 * round-to-integral-value | |
572 * | |
573 * TODO: implement | |
574 */ | |
575 Decimal rint(Decimal op1, Decimal op2) { | |
576 Decimal result; | |
577 return result; | |
578 } | |
579 | |
580 // logical operations | |
581 | |
582 /** | |
583 * part of spec | |
584 * | |
585 * TODO: implement | |
586 */ | |
587 Decimal and(Decimal op1, Decimal op2) { | |
588 Decimal result; | |
589 return result; | |
590 } | |
591 | |
592 /** | |
593 * part of spec | |
594 * | |
595 * TODO: implement | |
596 */ | |
597 Decimal or(Decimal op1, Decimal op2) { | |
598 Decimal result; | |
599 return result; | |
600 } | |
601 | |
602 /** | |
603 * part of spec | |
604 * | |
605 * TODO: implement | |
606 */ | |
607 Decimal xor(Decimal op1, Decimal op2) { | |
608 Decimal result; | |
609 return result; | |
610 } | |
611 | |
612 /** | |
613 * part of spec | |
614 * | |
615 * TODO: implement | |
616 */ | |
617 Decimal invert(Decimal op1) { | |
618 Decimal result; | |
619 return result; | |
620 } | |
621 | |
622 | |
623 /** | |
624 * part of spec | |
625 * | |
626 * TODO: implement | |
627 */ | |
628 Decimal compareTotal(Decimal op1, Decimal op2) { | |
629 Decimal result; | |
630 return result; | |
631 } | |
4
b37c218c1442
Initial development of BCD integers
Paul (paul.d.anderson@comcast.net)
parents:
1
diff
changeset
|
632 +/ |
0 | 633 |
634 |