MathParser: Use std::trunc instead of custom implementation

This commit is contained in:
Birunthan Mohanathas 2013-12-23 16:09:18 +00:00
parent 9e5a1f4a8f
commit dd38ed10e9
2 changed files with 3 additions and 6 deletions

View File

@ -99,7 +99,6 @@ struct Function
}; };
static double frac(double x); static double frac(double x);
static double trunc(double x);
static double rad(double deg); static double rad(double deg);
static double sgn(double x); static double sgn(double x);
static double neg(double x); static double neg(double x);
@ -848,11 +847,6 @@ static double frac(double x)
return modf(x, &y); return modf(x, &y);
} }
static double trunc(double x)
{
return (x >= 0.0) ? floor(x) : ceil(x);
}
static double rad(double deg) static double rad(double deg)
{ {
return (deg / 180.0) * M_PI; return (deg / 180.0) * M_PI;

View File

@ -61,6 +61,9 @@ public:
ParseAssert(L"1 ? 2 : 1 ? 4 : 5", 4.0); ParseAssert(L"1 ? 2 : 1 ? 4 : 5", 4.0);
ParseAssert(L"1 ? 2 : (1 ? 4 : 5)", 2.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"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; double value;