20 #ifndef LIB_UTIL_QUANT_H 21 #define LIB_UTIL_QUANT_H 36 return n > 0 and !(n & (n-1));
58 : div_t(div (num,den))
67 : ldiv_t(ldiv (num,den))
76 : lldiv_t(lldiv (num,den))
104 return (res.rem)? res.quot-1
122 if (0 > (num^den) && res.rem)
126 res.rem = den - (-res.rem);
153 return fabs (d1-d2) < DBL_EPSILON * fabs (d1+d2) * ulp
154 || fabs (d1-d2) < DBL_MIN;
182 const I MAX_POW =
sizeof(I)*CHAR_BIT - 1;
184 auto remove_power = [&](I pow) constexpr
186 if (pow > MAX_POW)
return;
187 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)