fp_private.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*******************************************************************************
  2. * *
  3. * File fp_private.h, *
  4. * All pack 4 dependencies for the MathLib elems plus some defines used *
  5. * throughout MathLib. *
  6. * *
  7. * Copyright © 1991 Apple Computer, Inc. All rights reserved. *
  8. * *
  9. * Written by Ali Sazegari, started on October 1991, *
  10. * *
  11. * W A R N I N G: This routine expects a 64 bit double model. *
  12. * *
  13. *******************************************************************************/
  14. #define NoException 0
  15. /*******************************************************************************
  16. * Values of constants. *
  17. *******************************************************************************/
  18. //#define SgnMask 0x8000
  19. #define dSgnMask 0x80000000
  20. #define sSgnMask 0x7FFFFFFF
  21. //#define ExpMask 0x7FFF
  22. #define dExpMask 0x7FF00000
  23. #define sExpMask 0xFF000000
  24. /* according to rounding BIG & SMALL are: */
  25. #define BIG 1.1e+300 /* used to deliver ±° or largest number, */
  26. #define SMALL 1.1e-300 /* used to deliver ±0 or smallest number. */
  27. #define InfExp 0x7FF
  28. #define dMaxExp 0x7FF00000
  29. #define MaxExpP1 1024
  30. #define MaxExp 1023
  31. #define DenormLimit -52
  32. //#define ManMask 0x80000000
  33. #define dManMask 0x00080000
  34. //#define IsItDenorm 0x80000000
  35. #define dIsItDenorm 0x00080000
  36. //#define xIsItSNaN 0x40000000
  37. #define dIsItSNaN 0x00080000
  38. #define dHighMan 0x000FFFFF
  39. #define dFirstBitSet 0x00080000
  40. #define BIAS 0x3FF
  41. //#define GetSign 0x8000
  42. #define dGetSign 0x80000000
  43. #define sGetSign 0x80000000
  44. //#define Infinity(x) ( x.hex.exponent & ExpMask ) == ExpMask
  45. #define dInfinity(x) ( x.hex.high & dExpMask ) == dExpMask
  46. #define sInfinity(x) ( ( x.hexsgl << 1 ) & sExpMask ) == sExpMask
  47. //#define Exponent(x) x.hex.exponent & ExpMask
  48. #define dExponent(x) x.hex.high & dExpMask
  49. #define sExponent(x) ( ( x.hexsgl << 1 ) & sExpMask )
  50. #define sZero(x) ( x.hexsgl & sSgnMask ) == 0
  51. //#define Sign(x) ( x.hex.exponent & SgnMask ) == SgnMask
  52. /*******************************************************************************
  53. * Types used in the auxiliary functions. *
  54. *******************************************************************************/
  55. typedef struct /* Hex representation of a double. */
  56. {
  57. #if defined(__BIG_ENDIAN__)
  58. unsigned long int high;
  59. unsigned long int low;
  60. #else
  61. unsigned long int low;
  62. unsigned long int high;
  63. #endif
  64. } dHexParts;
  65. typedef union
  66. {
  67. unsigned char byties[8];
  68. double dbl;
  69. } DblInHex;
  70. //enum boolean { FALSE, TRUE };
  71. /*******************************************************************************
  72. * Macros to access long subfields of a double value. *
  73. *******************************************************************************/
  74. #define highpartd(x) *((long *) &x)
  75. #define lowpartd(x) *((long *) &x + 1)
  76. enum {
  77. FP_SNAN = 0, /* signaling NaN
  78. */
  79. FP_QNAN = 1, /* quiet NaN
  80. */
  81. FP_INFINITE = 2, /* + or - infinity
  82. */
  83. FP_ZERO = 3, /* + or - zero
  84. */
  85. FP_NORMAL = 4, /* all normal numbers
  86. */
  87. FP_SUBNORMAL = 5 /* denormal numbers
  88. */
  89. };