From c74d7adac6be66130bc116097bd5a121dac89f5f Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Tue, 11 May 2021 18:36:59 +0200 Subject: [PATCH] LibM: Implement path for negative powers --- Userland/Libraries/LibM/math.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibM/math.cpp b/Userland/Libraries/LibM/math.cpp index 1a0cb993696..653adb61778 100644 --- a/Userland/Libraries/LibM/math.cpp +++ b/Userland/Libraries/LibM/math.cpp @@ -426,6 +426,10 @@ long double powl(long double x, long double y) NOEXCEPT result = 1.0l / result; return result; } + if (x < 0) { + return 1.l / exp2l(y * log2l(-x)); + } + return exp2l(y * log2l(x)); }