aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/numeric_helpers.h
blob: 20844029c276d8c8f732f51f9800f4d773899a57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

template <class T>
T DivCeil(const T& numerator, const T& denominator);

//! A version of division that is a bit less noisy around the situation
//! when numerator is almost divisible by denominator. Round up if the remainder
//! is at least half of denominator, otherwise round down.
template<class T>
T DivRound(const T& numerator, const T& denominator);

template <class T>
T RoundUp(const T& numerator, const T& denominator);

template <class T>
T RoundDown(const T& numerator, const T& denominator);

template <class T>
int GetSign(const T& value);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT

#define NUMERIC_HELPERS_INL_H_
#include "numeric_helpers-inl.h"
#undef NUMERIC_HELPERS_INL_H_