summaryrefslogtreecommitdiff
path: root/Userland/Tests
diff options
context:
space:
mode:
authorMițca Dumitru <dumitru0mitca@gmail.com>2021-03-07 22:23:57 +0200
committerAndreas Kling <kling@serenityos.org>2021-03-09 07:28:06 +0100
commit87b61b0eef2a5e3908cb83e319747f7ebf3bffd6 (patch)
tree95c3ed3726fa4610f2d1d11ff0645f252a0f974d /Userland/Tests
parent8f7aa1e03a8e053ffc087ba2ba592586ca246745 (diff)
downloadserenity-87b61b0eef2a5e3908cb83e319747f7ebf3bffd6.zip
LibM: Add scalbn and associated functions
Also implement ldexp in terms of them, and add ldexpl
Diffstat (limited to 'Userland/Tests')
-rw-r--r--Userland/Tests/LibM/test-math.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Tests/LibM/test-math.cpp b/Userland/Tests/LibM/test-math.cpp
index 555e05df30..63a979d4e9 100644
--- a/Userland/Tests/LibM/test-math.cpp
+++ b/Userland/Tests/LibM/test-math.cpp
@@ -26,6 +26,7 @@
#include <AK/TestSuite.h>
+#include <float.h>
#include <math.h>
TEST_CASE(trig)
@@ -203,4 +204,20 @@ TEST_CASE(nextafter)
EXPECT_EQ(nextafter_translator(Extractor(0x1, 0x419, 0x7d78400000000), Extractor(0x0, 0x0, 0x1)), Extractor(0x1, 0x419, 0x7d783ffffffff));
}
+TEST_CASE(scalbn)
+{
+ EXPECT(isnan(scalbn(NAN, 3)));
+ EXPECT(!isfinite(scalbn(INFINITY, 5)));
+ EXPECT_EQ(scalbn(0, 3), 0);
+ EXPECT_EQ(scalbn(15.3, 0), 15.3);
+
+ EXPECT_EQ(scalbn(0x0.0000000000008p-1022, 16), 0x0.0000000000008p-1006);
+ static constexpr auto biggest_subnormal = DBL_MIN - DBL_TRUE_MIN;
+ auto smallest_normal = scalbn(biggest_subnormal, 1);
+ Extractor ex(smallest_normal);
+ EXPECT(ex.exponent != 0);
+
+ EXPECT_EQ(scalbn(2.0, 4), 32.0);
+}
+
TEST_MAIN(Math)