aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-04-25 11:38:13 +0200
committerRenaud G <renaud@rolisteam.org>2015-04-25 11:38:13 +0200
commitb1557c9fef9d7fa4e0ddac1d6e108ef9981f1196 (patch)
treef26c50c536bdcda9dded2e6defd3e6f78000208d /node
parent5acfe8b8352ba028235e5ecf007d1b9b4fa3a0f8 (diff)
downloadOneRoll-b1557c9fef9d7fa4e0ddac1d6e108ef9981f1196.tar.gz
OneRoll-b1557c9fef9d7fa4e0ddac1d6e108ef9981f1196.zip
add error divide_by_zero
Diffstat (limited to 'node')
-rw-r--r--node/executionnode.h2
-rw-r--r--node/scalaroperatornode.cpp5
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;
}