2011-07-22 20:39:56 +05:30
|
|
|
#ifndef THINP_MATH_H
|
|
|
|
#define THINP_MATH_H
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
// Only works for integral types
|
|
|
|
template <typename T>
|
|
|
|
T div_up(T const &v, T const &divisor) {
|
|
|
|
return (v + (divisor - 1)) / divisor;
|
|
|
|
}
|
2011-09-02 19:52:46 +05:30
|
|
|
|
|
|
|
// Seemingly pointless function, but it coerces the arguments
|
|
|
|
// nicely.
|
|
|
|
template <typename T>
|
|
|
|
T div_down(T const &v, T const &divisor) {
|
|
|
|
return v / divisor;
|
|
|
|
}
|
2011-07-22 20:39:56 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|