]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_math.cpp
In the middle of major refactoring...
[architektonas] / src / base / rs_math.cpp
index 6bad02f3c0a999b56763c28d3d07a1e4778e1f75..fe3ba33676475f62a94abf84516308f8636d818d 100644 (file)
 
 #include "rs_math.h"
 
+#include <assert.h>                                                            // For test()
+#include <math.h>
+#include <errno.h>
+#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;