29 #ifndef LIB_UTIL_QUANT_H 30 #define LIB_UTIL_QUANT_H 60 : div_t(div (num,den))
69 : ldiv_t(ldiv (num,den))
78 : lldiv_t(lldiv (num,den))
106 return (res.rem)? res.quot-1
124 if (0 > (num^den) && res.rem)
128 res.rem = den - (-res.rem);
155 return fabs (d1-d2) < DBL_EPSILON * fabs (d1+d2) * ulp
156 || fabs (d1-d2) < DBL_MIN;
184 const I MAX_POW =
sizeof(I)*CHAR_BIT - 1;
186 auto remove_power = [&](I pow) constexpr
188 if (pow > MAX_POW)
return;
189 if (num >= I{1} << pow)
I floordiv(I num, I den)
floor function for integer arithmetics.
helper to treat int or long division uniformly
IDiv< I > floorwrap(I num, I den)
scale wrapping operation.
IDiv< I > iDiv(I num, I den)
bool almostEqual(double d1, double d2, unsigned int ulp=2)
epsilon comparison of doubles.
constexpr int ilog2(I num)
Integral binary logarithm (disregarding fractional part)