1 /*
2    File: dcg_arith.h
3    Defines some arithmetic support
4 
5    Copyright (C) 2008 Marc Seutter
6 
7    This library is free software: you can redistribute it and/or modify
8    it under the terms of the GNU Lesser General Public License as published
9    by the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU Lesser General Public License
18    along with this library.  If not, see <http://www.gnu.org/licenses/>.
19 
20    CVS ID: "$Id: dcg_arith.h,v 1.8 2008/06/28 13:41:17 marcs Exp $"
21 */
22 #ifndef IncDcgArith
23 #define IncDcgArith
24 
25 /* include math */
26 #include <math.h>
27 
28 /* exclude min and max for WIN32 */
29 #ifndef WIN32
30 #define max(a,b) (((a)<(b))?(b):(a))
31 #define min(a,b) (((a)>(b))?(b):(a))
32 #endif
33 
34 #define odd(a) ((a)&1)
35 #define even(a) (!((a)&1))
36 #define iabs(a) (((a)<0)?(-(a)):(a))
37 #define rabs(a) (((a)<0.0)?(-(a)):(a))
38 
39 #define power10(x) pow(10.0, ((real) x))
40 #define ipower2(a) (1<<(a))
41 #define ipower10(a) (ipower(10,a));
42 
43 int ilog2 (int nr);
44 int ilog10 (int nr);
45 int ipower (int nr, int exp);
46 int imod (int l, int r);
47 int irem (int l, int r);
48 
49 #endif /* IncDcgArith */
50