From ac9dbcda977a5b1db6b94bbed656f7e7c8890e03 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 7 Jun 2021 14:10:06 +0200 Subject: [PATCH] LibM: Implement nearbyint, nearbyintl and nearbyintf These are used by the ultima engine for scummvm. --- Userland/Libraries/LibM/math.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Userland/Libraries/LibM/math.cpp b/Userland/Libraries/LibM/math.cpp index 1ce7cebb53..1a0cb99369 100644 --- a/Userland/Libraries/LibM/math.cpp +++ b/Userland/Libraries/LibM/math.cpp @@ -1413,4 +1413,19 @@ float fminf(float x, float y) NOEXCEPT return x < y ? x : y; } + +long double nearbyintl(long double value) NOEXCEPT +{ + return internal_to_integer(value, RoundingMode { fegetround() }); +} + +double nearbyint(double value) NOEXCEPT +{ + return internal_to_integer(value, RoundingMode { fegetround() }); +} + +float nearbyintf(float value) NOEXCEPT +{ + return internal_to_integer(value, RoundingMode { fegetround() }); +} }