Merge branch 'main' into client-side-tests

This commit is contained in:
MihailRis 2026-07-07 18:53:27 +03:00
commit b4c8469264
5 changed files with 46 additions and 11 deletions

View file

@ -22,9 +22,26 @@ namespace {
}
inline double power(double base, int64_t power) {
if (power == 0) {
return 1.0;
}
uint64_t exp;
if (power < 0) {
base = 1.0 / base;
exp = static_cast<uint64_t>(-(power + 1)) + 1;
} else {
exp = static_cast<uint64_t>(power);
}
double result = 1.0;
for (int64_t i = 0; i < power; i++) {
result *= base;
while (exp > 0) {
if (exp & 1)
result *= base;
base *= base;
exp >>= 1;
}
return result;
}