]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/real.hh
* lily/tie.cc (get_configuration): don't crash if left_dot is NULL.
[lilypond.git] / flower / include / real.hh
1 /*
2   real.hh -- declare Real
3
4   source file of the Flower Library
5
6   (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #ifndef REAL_HH
10 #define REAL_HH
11
12 #include <algorithm>
13 #include <climits>
14 #include <cmath>
15
16 typedef double Real;
17 extern const Real infinity_f;
18 using namespace std;
19 using std::isnan;
20 using std::isinf;
21 using std::fabs;
22
23 template<class T> inline T abs (T x)
24 {
25   return x > 0 ? x : -x;
26 }
27
28 template<class T> inline int sign (T x)
29 {
30   if (x)
31     return x > T (0) ? 1 : -1;
32   return 0;
33 }
34
35 template<class T> inline T sqr (T x)
36 {
37   return x * x;
38 }
39
40 inline Real
41 distance (Real x, Real y)
42 {
43   return abs (x - y);
44 }
45
46 #endif