home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Headers / misckit / MiscBase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-23  |  1.7 KB  |  51 lines

  1. //
  2. //    MiscBase.h -- generic #defines that are useful to have
  3. //        Originally written by Drew Davidson
  4. //        Copyright (c) 1994 by Drew Davidson.
  5. //        Compiled from several files, modified and extended by
  6. //            Don Yacktman for inclusion into the MiscKit.
  7. //                Version 1.0.  All rights reserved.
  8. //        This notice may not be removed from this source code.
  9. //
  10. //    This object is included in the MiscKit by permission from the author
  11. //    and its use is governed by the MiscKit license, found in the file
  12. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  13. //    for a list of all applicable permissions and restrictions.
  14. //    
  15.  
  16. // Most of these lack the MISC prefix because that would be too cumbersome.
  17. // If this causes anyone grief, please let me know so that amendments can
  18. // be made.  --don.
  19.  
  20. #ifndef MISC_SKIP_FREE
  21. #import <misckit/FREE.h>
  22. #endif
  23.  
  24. #ifndef MISC_SKIP_SELECT
  25. #import <misckit/SELECT.h>
  26. #endif
  27.  
  28. // Number to compare to instead of zero for double precision numbers.
  29. #define EPSILON ((double)-0.0000001)
  30.  
  31. // Bound a variable to min and max
  32. #define BOUND_MIN(value,min)        ((value) < (min) ? (min):(value))
  33. #define BOUND_MAX(value,max)        ((value) > (max) ? (max):(value))
  34. #define BOUND(value,min,max)        (((value) < (min)) ? (min):(((value) > (max)) ? (max):(value)))
  35.  
  36. // Some useful numbers and math functions
  37. #define K            1000
  38. #define M            1000000
  39. #define ONE_MILLION    M
  40. #define ONE_BILLION (K * ONE_MILLION)
  41. #define Inf            (1.0 / 0.0)
  42. #define isnan(x)    ((x) != (x))
  43. #define isinf(x)    ((!isnan(x) && !finite(x)) ? (((x) < 0) ? -1 : 1) : 0)
  44.  
  45.  
  46. #define ObjectIsValid(_o) \
  47.     (_o && (strcmp( _o->isa->name, "FREED(id)" ) != 0) )
  48.  
  49. // For the truly anal retentive
  50. #define PLURAL_SUFFIX(num)        ((num == 1) ? "" : "s")
  51.