]>
Commit | Line | Data |
---|---|---|
a98bcbee AJ |
1 | #include "config.h" |
2 | #include "SquidMath.h" | |
3 | ||
4 | int | |
5 | Math::intPercent(const int a, const int b) | |
6 | { | |
7 | return b ? ((int) (100.0 * a / b + 0.5)) : 0; | |
8 | } | |
9 | ||
10 | double | |
11 | Math::doublePercent(const double a, const double b) | |
12 | { | |
13 | return b ? (100.0 * a / b) : 0.0; | |
14 | } | |
15 | ||
16 | double | |
17 | Math::doubleAverage(const double cur, const double newD, int N, const int max) | |
18 | { | |
19 | if (N > max) | |
20 | N = max; | |
21 | ||
22 | return (cur * (N - 1.0) + newD) / N; | |
23 | } | |
24 | ||
25 | int | |
26 | Math::intAverage(const int cur, const int newI, int n, const int max) | |
27 | { | |
28 | if (n > max) | |
29 | n = max; | |
30 | ||
31 | return (cur * (n - 1) + newI) / n; | |
32 | } |