#include "rs_math.h"
+#include <assert.h> // For test()
+#include <math.h>
+#include <errno.h>
+#include "fparser.h"
#include "rs_debug.h"
/**
return res;
}
-/**
- * Evaluates a mathematical expression and returns the result.
- * If an error occured, ok will be set to false (if ok isn't NULL).
- */
-//double RS_Math::eval(const QString& expr, bool* ok);
-
/**
* Evaluates a mathematical expression and returns the result.
* If an error occured, ok will be set to false (if ok isn't NULL).
*/
double RS_Math::eval(const QString & expr, bool * ok)
{
-#ifndef RS_NO_FPARSER
if (expr.isEmpty())
{
if (ok != NULL)
if (ret >= 0)
{
- if (ok != NULL)
+ if (ok)
*ok = false;
return 0.0;
}
- if (ok != NULL)
+ if (ok)
*ok = true;
return fp.Eval(NULL);
-#else
- //std::cerr << "RS_Math::eval: No FParser support compiled in.\n";
- return expr.toDouble();
-#endif
}
/**
{
// Remove zeros at the end:
while (valStr.at(valStr.length() - 1) == '0')
- {
valStr.truncate(valStr.length() - 1);
- }
if (valStr.at(valStr.length() - 1) == '.')
- {
valStr.truncate(valStr.length() - 1);
- }
}
return valStr;