diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-11-22 14:04:29 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-11-22 14:04:29 +0000 |
commit | 7ce331c01ce6eb7b3f5c715a38a24359da9c6ee2 (patch) | |
tree | 3a7e8476e868ae15f4da1b7ce26b2db6f434468c /libm/fp_private.h | |
parent | c117dd5fb183afb1a4790a6f6110d88704be6bf8 (diff) |
Totally rework the math library, this time based on the MacOs X
math library (which is itself based on the math lib from FreeBSD).
-Erik
Diffstat (limited to 'libm/fp_private.h')
-rw-r--r-- | libm/fp_private.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/libm/fp_private.h b/libm/fp_private.h new file mode 100644 index 000000000..30b3e0572 --- /dev/null +++ b/libm/fp_private.h @@ -0,0 +1,112 @@ +/******************************************************************************* +* * +* File fp_private.h, * +* All pack 4 dependencies for the MathLib elems plus some defines used * +* throughout MathLib. * +* * +* Copyright © 1991 Apple Computer, Inc. All rights reserved. * +* * +* Written by Ali Sazegari, started on October 1991, * +* * +* W A R N I N G: This routine expects a 64 bit double model. * +* * +*******************************************************************************/ + +#define NoException 0 + +/******************************************************************************* +* Values of constants. * +*******************************************************************************/ + +//#define SgnMask 0x8000 +#define dSgnMask 0x80000000 +#define sSgnMask 0x7FFFFFFF + +//#define ExpMask 0x7FFF +#define dExpMask 0x7FF00000 +#define sExpMask 0xFF000000 + + /* according to rounding BIG & SMALL are: */ +#define BIG 1.1e+300 /* used to deliver ±° or largest number, */ +#define SMALL 1.1e-300 /* used to deliver ±0 or smallest number. */ +#define InfExp 0x7FF +#define dMaxExp 0x7FF00000 + +#define MaxExpP1 1024 +#define MaxExp 1023 + +#define DenormLimit -52 + +//#define ManMask 0x80000000 +#define dManMask 0x00080000 + +//#define IsItDenorm 0x80000000 +#define dIsItDenorm 0x00080000 + +//#define xIsItSNaN 0x40000000 +#define dIsItSNaN 0x00080000 + +#define dHighMan 0x000FFFFF +#define dFirstBitSet 0x00080000 +#define BIAS 0x3FF + +//#define GetSign 0x8000 +#define dGetSign 0x80000000 +#define sGetSign 0x80000000 + +//#define Infinity(x) ( x.hex.exponent & ExpMask ) == ExpMask +#define dInfinity(x) ( x.hex.high & dExpMask ) == dExpMask +#define sInfinity(x) ( ( x.hexsgl << 1 ) & sExpMask ) == sExpMask + +//#define Exponent(x) x.hex.exponent & ExpMask +#define dExponent(x) x.hex.high & dExpMask +#define sExponent(x) ( ( x.hexsgl << 1 ) & sExpMask ) + +#define sZero(x) ( x.hexsgl & sSgnMask ) == 0 +//#define Sign(x) ( x.hex.exponent & SgnMask ) == SgnMask + +/******************************************************************************* +* Types used in the auxiliary functions. * +*******************************************************************************/ + +typedef struct /* Hex representation of a double. */ + { +#if defined(__BIG_ENDIAN__) + unsigned long int high; + unsigned long int low; +#else + unsigned long int low; + unsigned long int high; +#endif + } dHexParts; + +typedef union + { + unsigned char byties[8]; + double dbl; + } DblInHex; + +//enum boolean { FALSE, TRUE }; + +/******************************************************************************* +* Macros to access long subfields of a double value. * +*******************************************************************************/ + +#define highpartd(x) *((long *) &x) +#define lowpartd(x) *((long *) &x + 1) + +enum { + FP_SNAN = 0, /* signaling NaN + */ + FP_QNAN = 1, /* quiet NaN + */ + FP_INFINITE = 2, /* + or - infinity + */ + FP_ZERO = 3, /* + or - zero + */ + FP_NORMAL = 4, /* all normal numbers + */ + FP_SUBNORMAL = 5 /* denormal numbers + */ +}; + |