diff options
| -rw-r--r-- | node/executionnode.h | 2 | ||||
| -rw-r--r-- | node/scalaroperatornode.cpp | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/node/executionnode.h b/node/executionnode.h index cf1514f..cc40867 100644 --- a/node/executionnode.h +++ b/node/executionnode.h @@ -9,7 +9,7 @@ class ExecutionNode { public: - enum ERROR_CODE {NO_ERROR,DIE_RESULT_EXPECTED,BAD_SYNTAXE,ENDLESS_LOOP_ERROR}; + enum ERROR_CODE {NO_ERROR,DIE_RESULT_EXPECTED,BAD_SYNTAXE,ENDLESS_LOOP_ERROR,DIVIDE_BY_ZERO}; /** * @brief ExecutionNode */ diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp index 34eb6b8..8dfbc20 100644 --- a/node/scalaroperatornode.cpp +++ b/node/scalaroperatornode.cpp @@ -105,6 +105,11 @@ qint64 ScalarOperatorNode::substract(qint64 a,qint64 b) qreal ScalarOperatorNode::divide(qint64 a,qint64 b) { + if(b==0) + { + m_errors.append(DIVIDE_BY_ZERO); + return 0; + } return (qreal)a/b; } |