summaryrefslogtreecommitdiffhomepage
path: root/compat/math.hpp
blob: c5981cc26556793689277c4ae02ea7d43b59751a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once

#include <cmath>
#include <type_traits>

template<typename t>
inline auto iround(t val) -> std::enable_if_t<std::is_floating_point_v<std::decay_t<t>>, int>
{
    return (int)std::round(val);
}

template <typename t>
constexpr int signum(const t& x)
{
    return x < t{0} ? -1 : 1;
}