From 9ba9691d1941443c4da61bdd0bc9e01978ed43e2 Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Thu, 27 Jan 2022 13:23:36 +0100 Subject: [PATCH] AK: Use integral power for FixedPoint formatting This removes an ifdef for the Kernel --- AK/Format.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/AK/Format.cpp b/AK/Format.cpp index c71b6ddf5b..4c00e3f6da 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -383,14 +384,7 @@ ErrorOr FormatBuilder::put_fixed_point( // place to start would be the following video from CppCon 2019: // https://youtu.be/4P_kbF0EbZM (Stephan T. Lavavej “Floating-Point : Making Your Code 10x Faster With C++17's Final Boss”) -#ifdef KERNEL - // We don't have pow() in kernel land - u64 scale = 10; - for (size_t i = 0; i < precision - 1; i++) // TODO: not efficient - scale *= 10; -#else - u64 scale = pow(10.0, (double)precision); -#endif + u64 scale = pow(10, precision); auto fraction = (scale * fraction_value) / fraction_one; // TODO: overflows if (is_negative)