diff options
| author | 2015-04-25 11:38:13 +0200 | |
|---|---|---|
| committer | 2015-04-25 11:38:13 +0200 | |
| commit | b1557c9fef9d7fa4e0ddac1d6e108ef9981f1196 (patch) | |
| tree | f26c50c536bdcda9dded2e6defd3e6f78000208d | |
| parent | 5acfe8b8352ba028235e5ecf007d1b9b4fa3a0f8 (diff) | |
| download | OneRoll-b1557c9fef9d7fa4e0ddac1d6e108ef9981f1196.tar.gz OneRoll-b1557c9fef9d7fa4e0ddac1d6e108ef9981f1196.zip | |
add error divide_by_zero
| -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; } |