flower-1.0.27
[lilypond.git] / src / misc.cc
bloba8fe2c026dc16f09ba2fc705cb6fd598b1380224
1 #include "misc.hh"
2 #include "glob.hh"
3 #include "moment.hh"
5 #include <math.h>
7 Moment
8 wholes(int dur, int dots)
10 if (!dur)
11 return 0.0;
13 // stupid Intel: doesn't crash if !dur
14 Moment f = Rational(1)/Moment(dur);
15 Moment delta = f;
17 while (dots--) {
18 delta /= 2.0;
19 f += delta;
21 return f;
23 int
24 intlog2(int d) {
25 int i=0;
26 while (!(d&1)) {
27 d/= 2;
28 i++;
30 assert(!(d/2));
31 return i;
34 double
35 log_2(double x) {
36 return log(x) /log(2.0);