summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-13 19:00:55 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-13 19:01:44 +0100
commit3b2f20ed4d393b93de3dd84cf6290ec5fb089593 (patch)
tree2d8fe58556674341dbfe807e0f04a2e7279c1a78
parent65cb40632740b445ca71b7585cca27dae4d05fe3 (diff)
downloadserenity-3b2f20ed4d393b93de3dd84cf6290ec5fb089593.zip
LibM: Implement some naive functionality to make VVVVVV run
-rw-r--r--Libraries/LibM/math.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/Libraries/LibM/math.cpp b/Libraries/LibM/math.cpp
index 24810ffcd7..3c7f4bbaf9 100644
--- a/Libraries/LibM/math.cpp
+++ b/Libraries/LibM/math.cpp
@@ -64,11 +64,11 @@ double pow(double x, double y)
return exp(y * log(x));
}
-double ldexp(double, int exp)
+double ldexp(double x, int exp)
{
- (void)exp;
- ASSERT_NOT_REACHED();
- return 0;
+ // FIXME: Please fix me. I am naive.
+ double val = pow(2, exp);
+ return x * val;
}
double tanh(double x)
@@ -290,6 +290,16 @@ float roundf(float value)
return (float)(int)(value - 0.5f);
}
+double floor(double value)
+{
+ return (int)value;
+}
+
+double rint(double value)
+{
+ return (int)roundf(value);
+}
+
float ceilf(float value)
{
// FIXME: Please fix me. I am naive.
@@ -300,6 +310,16 @@ float ceilf(float value)
return as_int + 1;
}
+double ceil(double value)
+{
+ // FIXME: Please fix me. I am naive.
+ int as_int = (int)value;
+ if (value == (double)as_int) {
+ return (double)as_int;
+ }
+ return as_int + 1;
+}
+
double modf(double x, double* intpart)
{
*intpart = (double)((int)(x));