base/math/fpP.h

Go to the documentation of this file.
00001 /******************************************************************************* 00002 * * 00003 * File fpP.h, * 00004 * All pack 4 dependencies for the MathLib elems plus some defines used * 00005 * throughout MathLib. * 00006 * * 00007 * Copyright © 1991 Apple Computer, Inc. All rights reserved. * 00008 * * 00009 * Written by Ali Sazegari, started on October 1991, * 00010 * * 00011 * W A R N I N G: This routine expects a 64 bit double model. * 00012 * * 00013 *******************************************************************************/ 00014 00015 #define NoException 0 00016 00017 /******************************************************************************* 00018 * Values of constants. * 00019 *******************************************************************************/ 00020 00021 //#define SgnMask 0x8000 00022 #define dSgnMask 0x80000000 00023 #define sSgnMask 0x7FFFFFFF 00024 00025 //#define ExpMask 0x7FFF 00026 #define dExpMask 0x7FF00000 00027 #define sExpMask 0xFF000000 00028 00029 /* according to rounding BIG & SMALL are: */ 00030 #define BIG 1.1e+300 /* used to deliver ±° or largest number, */ 00031 #define SMALL 1.1e-300 /* used to deliver ±0 or smallest number. */ 00032 #define InfExp 0x7FF 00033 #define dMaxExp 0x7FF00000 00034 00035 #define MaxExpP1 1024 00036 #define MaxExp 1023 00037 00038 #define DenormLimit -52 00039 00040 //#define ManMask 0x80000000 00041 #define dManMask 0x00080000 00042 00043 //#define IsItDenorm 0x80000000 00044 #define dIsItDenorm 0x00080000 00045 00046 //#define xIsItSNaN 0x40000000 00047 #define dIsItSNaN 0x00080000 00048 00049 #define dHighMan 0x000FFFFF 00050 #define dFirstBitSet 0x00080000 00051 #define BIAS 0x3FF 00052 00053 //#define GetSign 0x8000 00054 #define dGetSign 0x80000000 00055 #define sGetSign 0x80000000 00056 00057 //#define Infinity(x) ( x.hex.exponent & ExpMask ) == ExpMask 00058 #define dInfinity(x) ( x.hex.high & dExpMask ) == dExpMask 00059 #define sInfinity(x) ( ( x.hexsgl << 1 ) & sExpMask ) == sExpMask 00060 00061 //#define Exponent(x) x.hex.exponent & ExpMask 00062 #define dExponent(x) x.hex.high & dExpMask 00063 #define sExponent(x) ( ( x.hexsgl << 1 ) & sExpMask ) 00064 00065 #define sZero(x) ( x.hexsgl & sSgnMask ) == 0 00066 //#define Sign(x) ( x.hex.exponent & SgnMask ) == SgnMask 00067 00068 /******************************************************************************* 00069 * Types used in the auxiliary functions. * 00070 *******************************************************************************/ 00071 00072 typedef struct /* Hex representation of a double. */ 00073 { 00074 #if defined(__BIG_ENDIAN__) 00075 unsigned long int high; 00076 unsigned long int low; 00077 #else 00078 unsigned long int low; 00079 unsigned long int high; 00080 #endif 00081 } dHexParts; 00082 00083 typedef union 00084 { 00085 unsigned char byties[8]; 00086 double dbl; 00087 } DblInHex; 00088 00089 //enum boolean { FALSE, TRUE }; 00090 00091 /******************************************************************************* 00092 * Macros to access long subfields of a double value. * 00093 *******************************************************************************/ 00094 00095 #define highpartd(x) *((long *) &x) 00096 #define lowpartd(x) *((long *) &x + 1) 00097 00098 enum { 00099 FP_SNAN = 0, /* signaling NaN 00100 */ 00101 FP_QNAN = 1, /* quiet NaN 00102 */ 00103 FP_INFINITE = 2, /* + or - infinity 00104 */ 00105 FP_ZERO = 3, /* + or - zero 00106 */ 00107 FP_NORMAL = 4, /* all normal numbers 00108 */ 00109 FP_SUBNORMAL = 5 /* denormal numbers 00110 */ 00111 }; 00112

Generated on Thu Nov 20 11:49:51 2008 for RTAI API by doxygen 1.3.8