X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Frs_math.cpp;h=fe3ba33676475f62a94abf84516308f8636d818d;hb=d774c2655ba2c3657a565f325411144452392277;hp=6bad02f3c0a999b56763c28d3d07a1e4778e1f75;hpb=89e127aa3dbd74d3158e6dbe0ca1703420c04395;p=architektonas diff --git a/src/base/rs_math.cpp b/src/base/rs_math.cpp index 6bad02f..fe3ba33 100644 --- a/src/base/rs_math.cpp +++ b/src/base/rs_math.cpp @@ -14,6 +14,10 @@ #include "rs_math.h" +#include // For test() +#include +#include +#include "fparser.h" #include "rs_debug.h" /** @@ -245,19 +249,12 @@ double RS_Math::eval(const QString & expr, double def) 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) @@ -297,20 +294,16 @@ double RS_Math::eval(const QString & expr, bool * ok) 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 } /** @@ -364,14 +357,10 @@ QString RS_Math::doubleToString(double value, int prec) { // 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;