home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / INCLUDE.ZIP / FAKEIEEE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.7 KB  |  71 lines

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