summaryrefslogtreecommitdiff
path: root/Libraries/LibM/math.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibM/math.cpp')
-rw-r--r--Libraries/LibM/math.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Libraries/LibM/math.cpp b/Libraries/LibM/math.cpp
index 38d9edec1d..021993e9d4 100644
--- a/Libraries/LibM/math.cpp
+++ b/Libraries/LibM/math.cpp
@@ -412,12 +412,18 @@ float roundf(float value)
float floorf(float value)
{
- return (int)value;
+ if (value >= 0)
+ return (int)value;
+ int intvalue = (int)value;
+ return ((float)intvalue == value) ? intvalue : intvalue - 1;
}
double floor(double value)
{
- return (int)value;
+ if (value >= 0)
+ return (int)value;
+ int intvalue = (int)value;
+ return ((double)intvalue == value) ? intvalue : intvalue - 1;
}
double rint(double value)