home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / RTLINSRC.ZIP / FAKEIEEE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  3.0 KB  |  75 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - fakeieee.h
  3.  *
  4.  *      fake IEEE floating point package interface
  5.  *-----------------------------------------------------------------------*/
  6.  
  7. /*[]------------------------------------------------------------[]*/
  8. /*|                                                              |*/
  9. /*|     C/C++ Run Time Library - Version 4.0                     |*/
  10. /*|                                                              |*/
  11. /*|                                                              |*/
  12. /*|     Copyright (c) 1991 by Borland International              |*/
  13. /*|     All Rights Reserved.                                     |*/
  14. /*|                                                              |*/
  15. /*[]------------------------------------------------------------[]*/
  16.  
  17. /*
  18.     If you do not have the IEEE-recommended functions discussed in
  19.     file ostreamf.c, and if any of these statements is true
  20.         (a) Your system does not use IEEE floating-point.
  21.         (b) Your system doesn't have Infinity or Not-A-Number.
  22.         (c) Your system won't generate runtime aborts on overflow,
  23.             Infinity, or Not-A-Number (NaN).
  24.         (d) You don't care about runtime aborts in stream I/O.
  25.     then you may use these simple definitions to get ostreamf.c up and
  26.     running quickly.
  27.  
  28.     Here we assume:
  29.         (1) There is no special representation for Infinities.
  30.         (2) There is no such thing as Not-A-Number (NaN).
  31. */
  32.  
  33. // The following define the kinds (classes) of a floating-point number
  34. #define FPSIGNAN        0       // signaling NaN
  35. #define FPQUIETNAN      1       // quiet NaN 
  36. #define FPNEGINF        2       // -infinity 
  37. #define FPNEG           3       // negative normalized nonzero 
  38. #define FPNEGDENOR      4       // negative denormalized 
  39. #define FPNEGZERO       5       // -0 
  40. #define FPPOSZERO       6       // +0 
  41. #define FPPOSDENOR      7       // positive denormalized 
  42. #define FPPOS           8       // positive normalized nonzero 
  43. #define FPPOSINF        9       // +infinity 
  44.  
  45.  
  46. /* Returns kind (class) of parmeter.
  47.  * We assume only positive, negative, or zero is possible.
  48.  * This function is pretty inefficient, but we make no assumptions
  49.  * whatever about floating-point representation.
  50.  */
  51. fpclass(long double d)
  52. {
  53.     return (d < 0.0) ? FPNEG : ((d == 0.0) ? FPPOSZERO : FPPOS);
  54. }
  55.  
  56. /* True if parameter is a NaN.
  57.  * We assume there is no such thing as a NaN.
  58.  */
  59. inline int fpisnan( long double ) { return 0; }
  60.  
  61. /* True if -inf < parameter < inf.
  62.  * We assume there are no infinities.
  63.  */
  64. inline int fpfinite( long double ) { return 1; }
  65.  
  66. /* Return the first value with the sign of the second,
  67.  * even if one is Infinity or a NaN.
  68.  * This function is pretty inefficient, but we make no assumptions
  69.  * whatever about floating-point representation.
  70.  */
  71. long double fpcopysign( long double d1, long double d2 )
  72. {
  73.     return ( d1 && ((d1 < 0.0) != (d2 < 0.0)) ) ? -d1 : d1;
  74. }
  75.