2 * IBM Accurate Mathematical Library
3 * Written by International Business Machines Corp.
4 * Copyright (C) 2001-2013 Free Software Foundation, Inc.
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
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
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
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 /************************************************************************/
21 /* MODULE_NAME: mpa.h */
34 /* Arithmetic functions for multiple precision numbers. */
35 /* Common types and definition */
36 /************************************************************************/
39 typedef struct {/* This structure holds the details of a multi-precision */
40 int e
; /* floating point number, x: d[0] holds its sign (-1,0 or 1) */
41 double d
[40]; /* e holds its exponent (...,-2,-1,0,1,2,...) and */
42 } mp_no
; /* d[1]...d[p] hold its mantissa digits. The value of x is, */
43 /* x = d[1]*r**(e-1) + d[2]*r**(e-2) + ... + d[p]*r**(e-p). */
44 /* Here r = 2**24, 0 <= d[i] < r and 1 <= p <= 32. */
45 /* p is a global variable. A multi-precision number is */
46 /* always normalized. Namely, d[1] > 0. An exception is */
47 /* a zero which is characterized by d[0] = 0. The terms */
48 /* d[p+1], d[p+2], ... of a none zero number have no */
49 /* significance and so are the terms e, d[1],d[2],... */
52 typedef union { int i
[2]; double d
; } number
;
54 extern const mp_no mpone
;
55 extern const mp_no mptwo
;
64 #define ABS(x) ((x) < 0 ? -(x) : (x))
66 int __acr(const mp_no
*, const mp_no
*, int);
67 void __cpy(const mp_no
*, mp_no
*, int);
68 void __mp_dbl(const mp_no
*, double *, int);
69 void __dbl_mp(double, mp_no
*, int);
70 void __add(const mp_no
*, const mp_no
*, mp_no
*, int);
71 void __sub(const mp_no
*, const mp_no
*, mp_no
*, int);
72 void __mul(const mp_no
*, const mp_no
*, mp_no
*, int);
73 void __dvd(const mp_no
*, const mp_no
*, mp_no
*, int);
75 extern void __mpatan (mp_no
*, mp_no
*, int);
76 extern void __mpatan2 (mp_no
*, mp_no
*, mp_no
*, int);
77 extern void __mpsqrt (mp_no
*, mp_no
*, int);
78 extern void __mpexp (mp_no
*, mp_no
*, int);
79 extern void __c32 (mp_no
*, mp_no
*, mp_no
*, int);
80 extern int __mpranred (double, mp_no
*, int);