Files
piphoto/intmath.h

12 lines
266 B
C
Raw Permalink Normal View History

2017-08-10 13:51:39 -07:00
#pragma once
template <typename T>
constexpr T AbsDiff(T a, T b) {
2017-08-12 07:38:18 -07:00
return std::abs(b - a);
2017-08-10 13:51:39 -07:00
}
template <typename T>
constexpr T Interpolate(T val0, T val1, T mul, T div) {
2017-08-12 11:46:05 -07:00
return val0 + static_cast<int32_t>((static_cast<int64_t>(mul) * (val1 - val0)) / div);
}