mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
AK: Move integral log2 and exp to IntegerMath.h
This commit is contained in:
parent
f6ddaef8bf
commit
fbb798f98c
8 changed files with 20 additions and 16 deletions
12
AK/Math.h
12
AK/Math.h
|
@ -295,12 +295,6 @@ constexpr T log2(T x)
|
|||
return ret;
|
||||
}
|
||||
|
||||
template<Integral T>
|
||||
constexpr T log2(T x)
|
||||
{
|
||||
return x ? (8 * sizeof(T) - 1) - count_leading_zeroes(static_cast<MakeUnsigned<T>>(x)) : 0;
|
||||
}
|
||||
|
||||
template<FloatingPoint T>
|
||||
constexpr T log10(T x)
|
||||
{
|
||||
|
@ -353,11 +347,7 @@ constexpr T exp2(T exponent)
|
|||
: "0"(exponent));
|
||||
return res;
|
||||
}
|
||||
template<Integral T>
|
||||
constexpr T exp2(T exponent)
|
||||
{
|
||||
return 1u << exponent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using Exponentials::exp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue