]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_math.cpp
Fixed Library Browser...
[architektonas] / src / base / rs_math.cpp
index 6bad02f3c0a999b56763c28d3d07a1e4778e1f75..1d2f848ddf321ad47b76b44997f3498c7396de92 100644 (file)
@@ -3,7 +3,9 @@
 // Part of the Architektonas Project
 // Originally part of QCad Community Edition by Andrew Mustun
 // Extensively rewritten and refactored by James L. Hammons
-// (C) 2010 Underground Software
+// Portions copyright (C) 2001-2003 RibbonSoft
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
 //
 // JLH = James L. Hammons <jlhamm@acm.org>
 //
 
 #include "rs_math.h"
 
+#include <assert.h>                                                            // For test()
+#include <math.h>
+#include <errno.h>
+#include "fparser.h"
 #include "rs_debug.h"
 
 /**
@@ -245,19 +251,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 +296,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 +359,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;