Blame sysdeps/ieee754/dbl-64/mpa.h

Packit 6c4009
/*
Packit 6c4009
 * IBM Accurate Mathematical Library
Packit 6c4009
 * Written by International Business Machines Corp.
Packit 6c4009
 * Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit 6c4009
 *
Packit 6c4009
 * This program is free software; you can redistribute it and/or modify
Packit 6c4009
 * it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
 * the Free Software Foundation; either version 2.1 of the License, or
Packit 6c4009
 * (at your option) any later version.
Packit 6c4009
 *
Packit 6c4009
 * This program is distributed in the hope that it will be useful,
Packit 6c4009
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 6c4009
 * GNU Lesser General Public License for more details.
Packit 6c4009
 *
Packit 6c4009
 * You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/************************************************************************/
Packit 6c4009
/*  MODULE_NAME: mpa.h                                                  */
Packit 6c4009
/*                                                                      */
Packit 6c4009
/*  FUNCTIONS:                                                          */
Packit 6c4009
/*               mcr                                                    */
Packit 6c4009
/*               acr                                                    */
Packit 6c4009
/*               cpy                                                    */
Packit 6c4009
/*               mp_dbl                                                 */
Packit 6c4009
/*               dbl_mp                                                 */
Packit 6c4009
/*               add                                                    */
Packit 6c4009
/*               sub                                                    */
Packit 6c4009
/*               mul                                                    */
Packit 6c4009
/*               dvd                                                    */
Packit 6c4009
/*                                                                      */
Packit 6c4009
/* Arithmetic functions for multiple precision numbers.                 */
Packit 6c4009
/* Common types and definition                                          */
Packit 6c4009
/************************************************************************/
Packit 6c4009
Packit 6c4009
#include <mpa-arch.h>
Packit 6c4009
Packit 6c4009
/* The mp_no structure holds the details of a multi-precision floating point
Packit 6c4009
   number.
Packit 6c4009
Packit 6c4009
   - The radix of the number (R) is 2 ^ 24.
Packit 6c4009
Packit 6c4009
   - E: The exponent of the number.
Packit 6c4009
Packit 6c4009
   - D[0]: The sign (-1, 1) or 0 if the value is 0.  In the latter case, the
Packit 6c4009
     values of the remaining members of the structure are ignored.
Packit 6c4009
Packit 6c4009
   - D[1] - D[p]: The mantissa of the number where:
Packit 6c4009
Packit 6c4009
	0 <= D[i] < R and
Packit 6c4009
	P is the precision of the number and 1 <= p <= 32
Packit 6c4009
Packit 6c4009
     D[p+1] ... D[39] have no significance.
Packit 6c4009
Packit 6c4009
   - The value of the number is:
Packit 6c4009
Packit 6c4009
	D[1] * R ^ (E - 1) + D[2] * R ^ (E - 2) ... D[p] * R ^ (E - p)
Packit 6c4009
Packit 6c4009
   */
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  int e;
Packit 6c4009
  mantissa_t d[40];
Packit 6c4009
} mp_no;
Packit 6c4009
Packit 6c4009
typedef union
Packit 6c4009
{
Packit 6c4009
  int i[2];
Packit 6c4009
  double d;
Packit 6c4009
} number;
Packit 6c4009
Packit 6c4009
extern const mp_no __mpone;
Packit 6c4009
extern const mp_no __mptwo;
Packit 6c4009
Packit 6c4009
#define  X   x->d
Packit 6c4009
#define  Y   y->d
Packit 6c4009
#define  Z   z->d
Packit 6c4009
#define  EX  x->e
Packit 6c4009
#define  EY  y->e
Packit 6c4009
#define  EZ  z->e
Packit 6c4009
Packit 6c4009
#ifndef RADIXI
Packit 6c4009
# define  RADIXI    0x1.0p-24		/* 2^-24   */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifndef TWO52
Packit 6c4009
# define  TWO52     0x1.0p52		/* 2^52    */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#define  TWO5      TWOPOW (5)		/* 2^5     */
Packit 6c4009
#define  TWO8      TWOPOW (8)		/* 2^52    */
Packit 6c4009
#define  TWO10     TWOPOW (10)		/* 2^10    */
Packit 6c4009
#define  TWO18     TWOPOW (18)		/* 2^18    */
Packit 6c4009
#define  TWO19     TWOPOW (19)		/* 2^19    */
Packit 6c4009
#define  TWO23     TWOPOW (23)		/* 2^23    */
Packit 6c4009
Packit 6c4009
#define  HALFRAD   TWO23
Packit 6c4009
Packit 6c4009
#define  TWO57     0x1.0p57		/* 2^57    */
Packit 6c4009
#define  TWO71     0x1.0p71		/* 2^71    */
Packit 6c4009
#define  TWOM1032  0x1.0p-1032		/* 2^-1032 */
Packit 6c4009
#define  TWOM1022  0x1.0p-1022		/* 2^-1022 */
Packit 6c4009
Packit 6c4009
#define  HALF      0x1.0p-1		/* 1/2 */
Packit 6c4009
#define  MHALF     -0x1.0p-1		/* -1/2 */
Packit 6c4009
Packit 6c4009
int __acr (const mp_no *, const mp_no *, int);
Packit 6c4009
void __cpy (const mp_no *, mp_no *, int);
Packit 6c4009
void __mp_dbl (const mp_no *, double *, int);
Packit 6c4009
void __dbl_mp (double, mp_no *, int);
Packit 6c4009
void __add (const mp_no *, const mp_no *, mp_no *, int);
Packit 6c4009
void __sub (const mp_no *, const mp_no *, mp_no *, int);
Packit 6c4009
void __mul (const mp_no *, const mp_no *, mp_no *, int);
Packit 6c4009
void __sqr (const mp_no *, mp_no *, int);
Packit 6c4009
void __dvd (const mp_no *, const mp_no *, mp_no *, int);
Packit 6c4009
Packit 6c4009
extern void __mpatan (mp_no *, mp_no *, int);
Packit 6c4009
extern void __mpatan2 (mp_no *, mp_no *, mp_no *, int);
Packit 6c4009
extern void __mpsqrt (mp_no *, mp_no *, int);
Packit 6c4009
extern void __c32 (mp_no *, mp_no *, mp_no *, int);
Packit 6c4009
extern int __mpranred (double, mp_no *, int);