src/Utils.cpp

changeset 20
fcbbddcc22c1
child 29
76846c99f827
equal deleted inserted replaced
19:c94edc758a5b 20:fcbbddcc22c1
1 /**
2 * Utils.cpp is part of bmsapp.
3 *
4 * bmsapp is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * bmsapp is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include "Utils.h"
18
19 #include <math.h>
20
21 double Utils::Round(double n, int d)
22 {
23 int m;
24
25 for (int i = 0, m = 1; i < d; i++, m *= 10);
26 return round(n * m) / m;
27 }
28
29
30 double Utils::lintner_to_kolbach(double lintner)
31 {
32 double wk = (3.5 * lintner) - 16;
33 if (wk < 0)
34 return 0.0;
35 return wk;
36 }
37
38
39 double Utils::kolbach_to_lintner(double kolbach)
40 {
41 return Round((kolbach + 16) / 3.5, 3);
42 }
43

mercurial