1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 /* HUGE_VAL is traditionally defined as positive infinity, or
26 alternatively, DBL_MAX. */
29 (fabs (X) == HUGE_VAL)
32 /* A Not a Number is not equal to itself. */
38 /* Finite numbers are not infinities or NaNs. */
41 (!isinf (X) && !isnan (X))
43 #include <ieeefp.h> /* Declares finite() under Solaris. */
47 #include <stdlib.h> /* screwed-up Borland headers define min(), max(),
48 so we might as well let 'em */
52 #if __GNUC__ && !__STRICT_ANSI__
55 int _a = (A), _b = (B); \
60 ((A) < (B) ? (A) : (B))
61 #endif /* !__GNUC__ */
65 #if __GNUC__ && !__STRICT_ANSI__
68 int _a = (A), _b = (B); \
73 ((A) > (B) ? (A) : (B))
74 #endif /* !__GNUC__ */
77 /* Clamps A to be between B and C. */
78 #define range(A, B, C) \
79 ((A) < (B) ? (B) : ((A) > (C) ? (C) : (A)))
81 /* Divides nonnegative X by positive Y, rounding up. */
82 #define DIV_RND_UP(X, Y) \
83 (((X) + ((Y) - 1)) / (Y))
85 /* Returns nonnegative difference between {nonnegative X} and {the
86 least multiple of positive Y greater than or equal to X}. */
87 #if __GNUC__ && !__STRICT_ANSI__
88 #define REM_RND_UP(X, Y) \
90 int rem = (X) % (Y); \
91 rem ? (Y) - rem : 0; \
94 #define REM_RND_UP(X, Y) \
95 ((X) % (Y) ? (Y) - (X) % (Y) : 0)
98 /* Rounds X up to the next multiple of Y. */
99 #define ROUND_UP(X, Y) \
100 (((X) + ((Y) - 1)) / (Y) * (Y))
102 /* Rounds X down to the previous multiple of Y. */
103 #define ROUND_DOWN(X, Y) \
106 int intlog10 (unsigned);
108 #endif /* math/misc.h */