home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscBase.h -- generic #defines that are useful to have
- // Originally written by Drew Davidson
- // Copyright (c) 1994 by Drew Davidson.
- // Compiled from several files, modified and extended by
- // Don Yacktman for inclusion into the MiscKit.
- // Version 1.0. All rights reserved.
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- // Most of these lack the MISC prefix because that would be too cumbersome.
- // If this causes anyone grief, please let me know so that amendments can
- // be made. --don.
-
- #ifndef MISC_SKIP_FREE
- #import <misckit/FREE.h>
- #endif
-
- #ifndef MISC_SKIP_SELECT
- #import <misckit/SELECT.h>
- #endif
-
- // Number to compare to instead of zero for double precision numbers.
- #define EPSILON ((double)-0.0000001)
-
- // Bound a variable to min and max
- #define BOUND_MIN(value,min) ((value) < (min) ? (min):(value))
- #define BOUND_MAX(value,max) ((value) > (max) ? (max):(value))
- #define BOUND(value,min,max) (((value) < (min)) ? (min):(((value) > (max)) ? (max):(value)))
-
- // Some useful numbers and math functions
- #define K 1000
- #define M 1000000
- #define ONE_MILLION M
- #define ONE_BILLION (K * ONE_MILLION)
- #define Inf (1.0 / 0.0)
- #define isnan(x) ((x) != (x))
- #define isinf(x) ((!isnan(x) && !finite(x)) ? (((x) < 0) ? -1 : 1) : 0)
-
-
- #define ObjectIsValid(_o) \
- (_o && (strcmp( _o->isa->name, "FREED(id)" ) != 0) )
-
- // For the truly anal retentive
- #define PLURAL_SUFFIX(num) ((num == 1) ? "" : "s")
-