summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendiadyoin1 <leon2002.la@gmail.com>2021-07-05 16:08:37 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-06 00:16:45 +0200
commit119f280f345caf08d13627c3ec4f83f14adb8054 (patch)
treefa44483b25a64e4bf86d71520c0fa8889aea8d79
parentfdb5367da154c6a0690a1663b8e9ade93f2fad8b (diff)
downloadserenity-119f280f345caf08d13627c3ec4f83f14adb8054.zip
LibM: Use fcos for cosine
For some reason we were using sin(x+M_PI_2) instead
-rw-r--r--Userland/Libraries/LibM/math.cpp29
1 files 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<float>(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));