SquidMath.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #include "squid.h"
10 #include "SquidMath.h"
11 
12 int
13 Math::intPercent(const int a, const int b)
14 {
15  return b ? ((int) (100.0 * a / b + 0.5)) : 0;
16 }
17 
18 int64_t
19 Math::int64Percent(const int64_t a, const int64_t b)
20 {
21  return b ? ((int64_t) (100.0 * a / b + 0.5)) : 0;
22 }
23 
24 double
25 Math::doublePercent(const double a, const double b)
26 {
27  return b ? (100.0 * a / b) : 0.0;
28 }
29 
30 double
31 Math::doubleAverage(const double cur, const double newD, int N, const int max)
32 {
33  if (N > max)
34  N = max;
35 
36  return (cur * (N - 1.0) + newD) / N;
37 }
38 
39 int
40 Math::intAverage(const int cur, const int newI, int n, const int max)
41 {
42  if (n > max)
43  n = max;
44 
45  return (cur * (n - 1) + newI) / n;
46 }
47 
int intAverage(const int, const int, int, const int)
Definition: SquidMath.cc:40
int64_t int64Percent(const int64_t a, const int64_t b)
Definition: SquidMath.cc:19
A const & max(A const &lhs, A const &rhs)
double doublePercent(const double, const double)
Definition: SquidMath.cc:25
double doubleAverage(const double, const double, int, const int)
Definition: SquidMath.cc:31
int cur
Definition: ModDevPoll.cc:76
bool SIGHDLR int STUB void int
Definition: stub_tools.cc:68
int intPercent(const int a, const int b)
Definition: SquidMath.cc:13
int a
Definition: membanger.c:50

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors