Debian Codegraph @

Xpjproject/pjlib/include/pj/compat/high_precision.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
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 02111-1307 USA
18 */
19 #ifndef __PJ_COMPAT_HIGH_PRECISION_H__
20 #define __PJ_COMPAT_HIGH_PRECISION_H__
21
22
23 #if defined(PJ_HAS_FLOATING_POINT) && PJ_HAS_FLOATING_POINT != 0
24 /*
25 * The first choice for high precision math is to use double.
26 */
27 # include <math.h>
28 typedef double pj_highprec_t;
29
30 # define PJ_HIGHPREC_VALUE_IS_ZERO(a) (a==0)
31 # define pj_highprec_mod(a,b) (a=fmod(a,b))
32
33 #elif defined(PJ_HAS_INT64) && PJ_HAS_INT64 != 0
34 /*
35 * Next choice is to use 64-bit arithmatics.
36 */
37 typedef pj_int64_t pj_highprec_t;
38
39 #else
40 # warning "High precision math is not available"
41
42 /*
43 * Last, fallback to 32-bit arithmetics.
44 */
45 typedef pj_int32_t pj_highprec_t;
46
47 #endif
48
49 /**
50 * @def pj_highprec_mul
51 * pj_highprec_mul(a1, a2) - High Precision Multiplication
52 * Multiply a1 and a2, and store the result in a1.
53 */
54 #ifndef pj_highprec_mul
55 # define pj_highprec_mul(a1,a2) (a1 = a1 * a2)
56 #endif
57
58 /**
59 * @def pj_highprec_div
60 * pj_highprec_div(a1, a2) - High Precision Division
61 * Divide a2 from a1, and store the result in a1.
62 */
63 #ifndef pj_highprec_div
64 # define pj_highprec_div(a1,a2) (a1 = a1 / a2)
65 #endif
66
67 /**
68 * @def pj_highprec_mod
69 * pj_highprec_mod(a1, a2) - High Precision Modulus
70 * Get the modulus a2 from a1, and store the result in a1.
71 */
72 #ifndef pj_highprec_mod
73 # define pj_highprec_mod(a1,a2) (a1 = a1 % a2)
74 #endif
75
76
77 /**
78 * @def PJ_HIGHPREC_VALUE_IS_ZERO(a)
79 * Test if the specified high precision value is zero.
80 */
81 #ifndef PJ_HIGHPREC_VALUE_IS_ZERO
82 # define PJ_HIGHPREC_VALUE_IS_ZERO(a) (a==0)
83 #endif
84
85
86 #endif /* __PJ_COMPAT_HIGH_PRECISION_H__ */
87