Merge from mainline
[official-gcc.git] / libgcc-math / dbl-64 / mpa.h
blob14a446baf9776de9e9383f8ee5eaad2dfef2ce84
2 /*
3 * IBM Accurate Mathematical Library
4 * Written by International Business Machines Corp.
5 * Copyright (C) 2001 Free Software Foundation, Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /************************************************************************/
23 /* MODULE_NAME: mpa.h */
24 /* */
25 /* FUNCTIONS: */
26 /* mcr */
27 /* acr */
28 /* cr */
29 /* cpy */
30 /* cpymn */
31 /* mp_dbl */
32 /* dbl_mp */
33 /* add */
34 /* sub */
35 /* mul */
36 /* inv */
37 /* dvd */
38 /* */
39 /* Arithmetic functions for multiple precision numbers. */
40 /* Common types and definition */
41 /************************************************************************/
43 #ifndef MPA_H
44 #define MPA_H
46 typedef struct {/* This structure holds the details of a multi-precision */
47 int e; /* floating point number, x: d[0] holds its sign (-1,0 or 1) */
48 double d[40]; /* e holds its exponent (...,-2,-1,0,1,2,...) and */
49 } mp_no; /* d[1]...d[p] hold its mantissa digits. The value of x is, */
50 /* x = d[1]*r**(e-1) + d[2]*r**(e-2) + ... + d[p]*r**(e-p). */
51 /* Here r = 2**24, 0 <= d[i] < r and 1 <= p <= 32. */
52 /* p is a global variable. A multi-precision number is */
53 /* always normalized. Namely, d[1] > 0. An exception is */
54 /* a zero which is characterized by d[0] = 0. The terms */
55 /* d[p+1], d[p+2], ... of a none zero number have no */
56 /* significance and so are the terms e, d[1],d[2],... */
57 /* of a zero. */
59 typedef union { int i[2]; double d; } number;
61 #define X x->d
62 #define Y y->d
63 #define Z z->d
64 #define EX x->e
65 #define EY y->e
66 #define EZ z->e
68 #define ABS(x) ((x) < 0 ? -(x) : (x))
69 #define MIN(a,b) (((a)<(b))?(a):(b))
71 int __acr(const mp_no *, const mp_no *, int);
72 int __cr(const mp_no *, const mp_no *, int);
73 void __cpy(const mp_no *, mp_no *, int);
74 void __cpymn(const mp_no *, int, mp_no *, int);
75 void __mp_dbl(const mp_no *, double *, int);
76 void __dbl_mp(double, mp_no *, int);
77 void __add(const mp_no *, const mp_no *, mp_no *, int);
78 void __sub(const mp_no *, const mp_no *, mp_no *, int);
79 void __mul(const mp_no *, const mp_no *, mp_no *, int);
80 void __inv(const mp_no *, mp_no *, int);
81 void __dvd(const mp_no *, const mp_no *, mp_no *, int);
83 extern void __mpatan (mp_no *, mp_no *, int);
84 extern void __mpatan2 (mp_no *, mp_no *, mp_no *, int);
85 extern void __mpsqrt (mp_no *, mp_no *, int);
86 extern void __mpexp (mp_no *, mp_no *__y, int);
87 extern void __c32 (mp_no *, mp_no *, mp_no *, int);
88 extern int __mpranred (double, mp_no *, int);
90 #endif