]>
Commit | Line | Data |
---|---|---|
e4d82761 UD |
1 | /* |
2 | * IBM Accurate Mathematical Library | |
c6c6dd48 | 3 | * Written by International Business Machines Corp. |
568035b7 | 4 | * Copyright (C) 2001-2013 Free Software Foundation, Inc. |
e4d82761 UD |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU Lesser General Public License as published by | |
cc7375ce | 8 | * the Free Software Foundation; either version 2.1 of the License, or |
e4d82761 | 9 | * (at your option) any later version. |
50944bca | 10 | * |
e4d82761 UD |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
c6c6dd48 | 14 | * GNU Lesser General Public License for more details. |
e4d82761 UD |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public License | |
59ba27a6 | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
e4d82761 | 18 | */ |
c6c6dd48 | 19 | |
e4d82761 UD |
20 | /************************************************************************/ |
21 | /* MODULE_NAME: mpa.h */ | |
22 | /* */ | |
23 | /* FUNCTIONS: */ | |
24 | /* mcr */ | |
25 | /* acr */ | |
e4d82761 | 26 | /* cpy */ |
e4d82761 UD |
27 | /* mp_dbl */ |
28 | /* dbl_mp */ | |
29 | /* add */ | |
30 | /* sub */ | |
31 | /* mul */ | |
e4d82761 UD |
32 | /* dvd */ |
33 | /* */ | |
34 | /* Arithmetic functions for multiple precision numbers. */ | |
35 | /* Common types and definition */ | |
36 | /************************************************************************/ | |
37 | ||
38 | ||
a9e48ab4 SP |
39 | /* The mp_no structure holds the details of a multi-precision floating point |
40 | number. | |
41 | ||
42 | - The radix of the number (R) is 2 ^ 24. | |
43 | ||
44 | - E: The exponent of the number. | |
45 | ||
46 | - D[0]: The sign (-1, 1) or 0 if the value is 0. In the latter case, the | |
47 | values of the remaining members of the structure are ignored. | |
48 | ||
49 | - D[1] - D[p]: The mantissa of the number where: | |
50 | ||
51 | 0 <= D[i] < R and | |
52 | P is the precision of the number and 1 <= p <= 32 | |
53 | ||
54 | D[p+1] ... D[39] have no significance. | |
55 | ||
56 | - The value of the number is: | |
57 | ||
58 | D[1] * R ^ (E - 1) + D[2] * R ^ (E - 2) ... D[p] * R ^ (E - p) | |
59 | ||
60 | */ | |
61 | typedef struct { | |
62 | int e; | |
63 | double d[40]; | |
64 | } mp_no; | |
e4d82761 UD |
65 | |
66 | typedef union { int i[2]; double d; } number; | |
67 | ||
b76eb5f0 | 68 | extern const mp_no mpone; |
da08f647 | 69 | extern const mp_no mptwo; |
b76eb5f0 | 70 | |
e4d82761 UD |
71 | #define X x->d |
72 | #define Y y->d | |
73 | #define Z z->d | |
74 | #define EX x->e | |
75 | #define EY y->e | |
76 | #define EZ z->e | |
77 | ||
e4d82761 UD |
78 | #define ABS(x) ((x) < 0 ? -(x) : (x)) |
79 | ||
31d3cc00 | 80 | int __acr(const mp_no *, const mp_no *, int); |
ca58f1db | 81 | void __cpy(const mp_no *, mp_no *, int); |
50944bca | 82 | void __mp_dbl(const mp_no *, double *, int); |
ca58f1db UD |
83 | void __dbl_mp(double, mp_no *, int); |
84 | void __add(const mp_no *, const mp_no *, mp_no *, int); | |
85 | void __sub(const mp_no *, const mp_no *, mp_no *, int); | |
86 | void __mul(const mp_no *, const mp_no *, mp_no *, int); | |
ca58f1db | 87 | void __dvd(const mp_no *, const mp_no *, mp_no *, int); |
1d052247 AJ |
88 | |
89 | extern void __mpatan (mp_no *, mp_no *, int); | |
90 | extern void __mpatan2 (mp_no *, mp_no *, mp_no *, int); | |
91 | extern void __mpsqrt (mp_no *, mp_no *, int); | |
302913e1 | 92 | extern void __mpexp (mp_no *, mp_no *, int); |
1d052247 AJ |
93 | extern void __c32 (mp_no *, mp_no *, mp_no *, int); |
94 | extern int __mpranred (double, mp_no *, int); |