10 #ifndef ICARUSALG_UTILITIES_ROUNDING_H
11 #define ICARUSALG_UTILITIES_ROUNDING_H
19 namespace icarus::ns::util {
21 template <
typename T,
typename U>
24 template <
typename T,
typename U>
25 constexpr T
roundup(T
const value, U
const quantum, T
const offset = T{});
66 template <
typename T,
typename U>
68 (T
const value, U
const quantum, T
const offset )
71 static_cast<T
>(offset + quantum * std::floor((value - offset) / quantum));
110 template <
typename T,
typename U>
112 (T
const value, U
const quantum, T
const offset )
114 T
const rounded =
rounddown(value, quantum, offset);
115 return (rounded < value)?
static_cast<T
>(rounded + quantum): rounded;
122 #endif // ICARUSALG_UTILITIES_ROUNDING_H
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
constexpr T roundup(T const value, U const quantum, T const offset=T{})
Returns the value, rounded up.
constexpr T rounddown(T const value, U const quantum, T const offset=T{})
Returns the value, rounded down.