]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/real.hh
* Another grand 2003 update.
[lilypond.git] / flower / include / real.hh
1 /*
2   real.hh -- declare Real
3
4   source file of the Flower Library
5
6   (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef REAL_HH
11 #define REAL_HH
12
13
14 #include <limits.h>
15
16 typedef double Real;
17 extern const Real infinity_f;
18
19 template<class T> inline T abs (T x)
20 {
21   return x > 0 ? x : -x;
22 }
23
24 template<class T> inline int sign (T x)
25 {
26   if (x)
27     return x > T (0) ? 1 : -1;
28   return 0;
29 }
30
31 template<class T> inline T max (T x, T y)
32 {
33   return x >? y;
34 }
35
36 template<class T> inline T sqr (T x)
37 {
38   return x*x;
39 }
40
41
42 template<class T> inline T min (T x, T y)
43 {
44   return x <? y;
45 }
46
47 inline Real
48 distance (Real x,Real y)
49 {
50     return abs (x-y);
51 }
52
53 #endif