mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Move integral log2 and exp to IntegerMath.h
This commit is contained in:
parent
f6ddaef8bf
commit
fbb798f98c
Notes:
sideshowbarker
2024-07-17 19:42:16 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/fbb798f98c8 Pull-request: https://github.com/SerenityOS/serenity/pull/12163 Reviewed-by: https://github.com/BertalanD ✅
8 changed files with 20 additions and 16 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
|
@ -13,6 +14,18 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
template<Integral T>
|
||||
constexpr T exp2(T exponent)
|
||||
{
|
||||
return 1u << exponent;
|
||||
}
|
||||
|
||||
template<Integral T>
|
||||
constexpr T log2(T x)
|
||||
{
|
||||
return x ? (8 * sizeof(T) - 1) - count_leading_zeroes(static_cast<MakeUnsigned<T>>(x)) : 0;
|
||||
}
|
||||
|
||||
template<Integral I>
|
||||
constexpr I pow(I base, I exponent)
|
||||
{
|
||||
|
|
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;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Math.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Devices/Device.h>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "RollWidget.h"
|
||||
#include "TrackManager.h"
|
||||
#include <AK/Math.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Scrollbar.h>
|
||||
#include <LibGfx/Font.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "GameSizeDialog.h"
|
||||
#include "Game.h"
|
||||
#include <AK/Math.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/CheckBox.h>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/FixedArray.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Math.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Math.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Memory.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "MatroskaDocument.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Math.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
|
Loading…
Reference in a new issue