]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/real.hh
* flower
[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 <climits>
13
14 typedef double Real;
15 extern const Real infinity_f;
16
17 template<class T> inline T abs (T x)
18 {
19   return x > 0 ? x : -x;
20 }
21
22 template<class T> inline int sign (T x)
23 {
24   if (x)
25     return x > T (0) ? 1 : -1;
26   return 0;
27 }
28
29 template<class T> inline T max (T x, T y)
30 {
31   return x >? y;
32 }
33
34 template<class T> inline T sqr (T x)
35 {
36   return x*x;
37 }
38
39 template<class T> inline T min (T x, T y)
40 {
41   return x <? y;
42 }
43
44 inline Real
45 distance (Real x, Real y)
46 {
47   return abs (x - y);
48 }
49
50 #endif