From 119f280f345caf08d13627c3ec4f83f14adb8054 Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Mon, 5 Jul 2021 16:08:37 +0200 Subject: LibM: Use fcos for cosine For some reason we were using sin(x+M_PI_2) instead --- Userland/Libraries/LibM/math.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibM/math.cpp b/Userland/Libraries/LibM/math.cpp index 53a7d522c4..dbc953b1fd 100644 --- a/Userland/Libraries/LibM/math.cpp +++ b/Userland/Libraries/LibM/math.cpp @@ -357,23 +357,40 @@ long double truncl(long double x) NOEXCEPT long double cosl(long double angle) NOEXCEPT { - return sinl(angle + M_PI_2); + long double ret = 0.0; + asm( + "fcos" + : "=t"(ret) + : "0"(angle)); + return ret; } double cos(double angle) NOEXCEPT { - return sin(angle + M_PI_2); + double ret = 0.0; + asm( + "fcos" + : "=t"(ret) + : "0"(angle)); + + return ret; } float cosf(float angle) NOEXCEPT { - return sinf(angle + static_cast(M_PI_2)); + float ret = 0.0; + asm( + "fcos" + : "=t"(ret) + : "0"(angle)); + + return ret; } long double sinl(long double angle) NOEXCEPT { long double ret = 0.0; - __asm__( + asm( "fsin" : "=t"(ret) : "0"(angle)); @@ -388,7 +405,7 @@ long double sinl(long double angle) NOEXCEPT double sin(double angle) NOEXCEPT { double ret = 0.0; - __asm__( + asm( "fsin" : "=t"(ret) : "0"(angle)); @@ -399,7 +416,7 @@ double sin(double angle) NOEXCEPT float sinf(float angle) NOEXCEPT { float ret = 0.0f; - __asm__( + asm( "fsin" : "=t"(ret) : "0"(angle)); -- cgit v1.2.3