diff --git a/Common/MathParser.cpp b/Common/MathParser.cpp index e47a9fca..a8a0c922 100644 --- a/Common/MathParser.cpp +++ b/Common/MathParser.cpp @@ -99,7 +99,6 @@ struct Function }; static double frac(double x); -static double trunc(double x); static double rad(double deg); static double sgn(double x); static double neg(double x); @@ -848,11 +847,6 @@ static double frac(double x) return modf(x, &y); } -static double trunc(double x) -{ - return (x >= 0.0) ? floor(x) : ceil(x); -} - static double rad(double deg) { return (deg / 180.0) * M_PI; diff --git a/Common/MathParser_Test.cpp b/Common/MathParser_Test.cpp index a1325ef2..3ba60239 100644 --- a/Common/MathParser_Test.cpp +++ b/Common/MathParser_Test.cpp @@ -61,6 +61,9 @@ public: ParseAssert(L"1 ? 2 : 1 ? 4 : 5", 4.0); ParseAssert(L"1 ? 2 : (1 ? 4 : 5)", 2.0); ParseAssert(L"0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:(0?1:5)))))))))))))))))))))))))))))", 5.0); + ParseAssert(L"trunc(1.5)", 1.0); + ParseAssert(L"trunc(-1.5)", -1.0); + ParseAssert(L"round(1.555, 2)", 1.56); double value;