blob: 6211772030d19c8486d1e62ff7a2a3b15bd6c27f (
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
|
#include <cstdint>
namespace OpenVic::NumberUtils {
constexpr int64_t round_to_int64(float num) {
return (num > 0.0f) ? (num + 0.5f) : (num - 0.5f);
}
constexpr int64_t round_to_int64(double num) {
return (num > 0.0) ? (num + 0.5) : (num - 0.5);
}
constexpr uint64_t pow(uint64_t base, size_t exponent) {
uint64_t ret = 1;
while (exponent-- > 0) {
ret *= base;
}
return ret;
}
constexpr int64_t pow(int64_t base, size_t exponent) {
int64_t ret = 1;
while (exponent-- > 0) {
ret *= base;
}
return ret;
}
}
|