From 88d342d007579c219fc1ac6748057316f4e93163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C8=9Bca=20Dumitru?= Date: Sun, 7 Mar 2021 23:21:39 +0200 Subject: [PATCH] LibM: Implement the frexp family --- Userland/Libraries/LibM/math.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibM/math.cpp b/Userland/Libraries/LibM/math.cpp index da0e6d3c11..e0cd0a8a1a 100644 --- a/Userland/Libraries/LibM/math.cpp +++ b/Userland/Libraries/LibM/math.cpp @@ -663,22 +663,22 @@ long double log2l(long double x) NOEXCEPT return log2(x); } -double frexp(double, int*) NOEXCEPT +double frexp(double x, int* exp) NOEXCEPT { - VERIFY_NOT_REACHED(); - return 0; + *exp = (x == 0) ? 0 : (1 + ilogb(x)); + return scalbn(x, -(*exp)); } -float frexpf(float, int*) NOEXCEPT +float frexpf(float x, int* exp) NOEXCEPT { - VERIFY_NOT_REACHED(); - return 0; + *exp = (x == 0) ? 0 : (1 + ilogbf(x)); + return scalbnf(x, -(*exp)); } -long double frexpl(long double, int*) NOEXCEPT +long double frexpl(long double x, int* exp) NOEXCEPT { - VERIFY_NOT_REACHED(); - return 0; + *exp = (x == 0) ? 0 : (1 + ilogbl(x)); + return scalbnl(x, -(*exp)); } double round(double value) NOEXCEPT