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., 51 Franklin Street, Fifth Floor, Boston, MA
26 #define EPSILON (10 * DBL_EPSILON)
28 /* HUGE_VAL is traditionally defined as positive infinity, or
29 alternatively, DBL_MAX. */
31 #define isinf(X) (fabs (X) == HUGE_VAL)
34 /* A Not a Number is not equal to itself. */
36 #define isnan(X) ((X) != (X))
39 /* Finite numbers are not infinities or NaNs. */
41 #define finite(X) (!isinf (X) && !isnan (X))
43 #include <ieeefp.h> /* Declares finite() under Solaris. */
47 #define min(A, B) ((A) < (B) ? (A) : (B))
51 #define max(A, B) ((A) > (B) ? (A) : (B))
54 /* Clamps A to be between B and C. */
55 #define range(A, B, C) ((A) < (B) ? (B) : ((A) > (C) ? (C) : (A)))
57 /* Divides nonnegative X by positive Y, rounding up. */
58 #define DIV_RND_UP(X, Y) (((X) + ((Y) - 1)) / (Y))
60 /* Returns nonnegative difference between {nonnegative X} and {the
61 least multiple of positive Y greater than or equal to X}. */
62 #define REM_RND_UP(X, Y) ((X) % (Y) ? (Y) - (X) % (Y) : 0)
64 /* Rounds X up to the next multiple of Y. */
65 #define ROUND_UP(X, Y) (((X) + ((Y) - 1)) / (Y) * (Y))
67 /* Rounds X down to the previous multiple of Y. */
68 #define ROUND_DOWN(X, Y) ((X) / (Y) * (Y))
70 int intlog10 (unsigned);
72 /* Returns the square of X. */
79 /* Returns the cube of X. */
86 /* Returns the fourth power of X. */
95 #endif /* math/misc.h */