10 #include "../stdafx.h"
13 #include "../safeguards.h"
24 int random_like = ((a + b) * (a - b)) % b;
26 int remainder = a % b;
29 if (
abs(random_like) <
abs(remainder)) {
30 ret += ((a < 0) ^ (b < 0)) ? -1 : 1;
45 uint32_t bit = 1UL << 30;
48 while (bit > num) bit >>= 2;
51 if (num >= res + bit) {
53 res = (res >> 1) + bit;
int DivideApprox(int a, int b)
Deterministic approximate division.
uint32_t IntSqrt(uint32_t num)
Compute the integer square root.
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.