#include "base/scriptframe.hpp"
#include "base/initialize.hpp"
#include <boost/math/special_functions/round.hpp>
+#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/foreach.hpp>
#include <cmath>
return std::tan(x);
}
+static bool MathIsnan(double x)
+{
+ return boost::math::isnan(x);
+}
+
+static bool MathIsinf(double x)
+{
+ return boost::math::isinf(x);
+}
+
+static double MathSign(double x)
+{
+ if (x > 0)
+ return 1;
+ else if (x < 0)
+ return -1;
+ else
+ return 0;
+}
+
static void InitializeMathObj(void)
{
Dictionary::Ptr mathObj = new Dictionary();
mathObj->Set("sin", new ScriptFunction(WrapScriptFunction(MathSin)));
mathObj->Set("sqrt", new ScriptFunction(WrapScriptFunction(MathSqrt)));
mathObj->Set("tan", new ScriptFunction(WrapScriptFunction(MathTan)));
+ mathObj->Set("isnan", new ScriptFunction(WrapScriptFunction(MathIsnan)));
+ mathObj->Set("isinf", new ScriptFunction(WrapScriptFunction(MathIsinf)));
+ mathObj->Set("sign", new ScriptFunction(WrapScriptFunction(MathSign)));
ScriptGlobal::Set("Math", mathObj);
}
if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) < static_cast<String>(rhs);
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
- return static_cast<int>(lhs) < static_cast<int>(rhs);
+ return static_cast<double>(lhs) < static_cast<double>(rhs);
else if (lhs.GetTypeName() != rhs.GetTypeName())
return lhs.GetTypeName() < rhs.GetTypeName();
else
if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) > static_cast<String>(rhs);
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
- return static_cast<int>(lhs) > static_cast<int>(rhs);
+ return static_cast<double>(lhs) > static_cast<double>(rhs);
else if (lhs.GetTypeName() != rhs.GetTypeName())
return lhs.GetTypeName() > rhs.GetTypeName();
else
if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) <= static_cast<String>(rhs);
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
- return static_cast<int>(lhs) <= static_cast<int>(rhs);
+ return static_cast<double>(lhs) <= static_cast<double>(rhs);
else if (lhs.GetTypeName() != rhs.GetTypeName())
return lhs.GetTypeName() <= rhs.GetTypeName();
else
if (lhs.IsString() && rhs.IsString())
return static_cast<String>(lhs) >= static_cast<String>(rhs);
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
- return static_cast<int>(lhs) >= static_cast<int>(rhs);
+ return static_cast<double>(lhs) >= static_cast<double>(rhs);
else if (lhs.GetTypeName() != rhs.GetTypeName())
return lhs.GetTypeName() >= rhs.GetTypeName();
else