summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibM/math.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Libraries/LibM/math.cpp b/Libraries/LibM/math.cpp
index 012d3e0ff8..51af8796ff 100644
--- a/Libraries/LibM/math.cpp
+++ b/Libraries/LibM/math.cpp
@@ -276,14 +276,20 @@ long double frexpl(long double, int*)
float roundf(float value)
{
- // FIXME: Please fix me. I am sad.
- return (int)value;
+ // FIXME: Please fix me. I am naive.
+ if (value >= 0.0f)
+ return (float)(int)(value + 0.5f);
+ return (float)(int)(value - 0.5f);
}
float ceilf(float value)
{
- // FIXME: Please fix me. I am sad.
- return (int)value;
+ // FIXME: Please fix me. I am naive.
+ int as_int = (int)value;
+ if (value == (float)as_int) {
+ return (float)as_int;
+ }
+ return as_int + 1;
}
}