]> git.ipfire.org Git - thirdparty/squid.git/blame - src/SquidMath.cc
Experiment: file internal extern declaration for C/C++ crossover
[thirdparty/squid.git] / src / SquidMath.cc
CommitLineData
a98bcbee
AJ
1#include "config.h"
2#include "SquidMath.h"
3
4int
5Math::intPercent(const int a, const int b)
6{
7 return b ? ((int) (100.0 * a / b + 0.5)) : 0;
8}
9
10double
11Math::doublePercent(const double a, const double b)
12{
13 return b ? (100.0 * a / b) : 0.0;
14}
15
16double
17Math::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
25int
26Math::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}