From 5d19d0660c395cf500c01c9f3f1e451f6914080b Mon Sep 17 00:00:00 2001 From: bajb Date: Fri, 1 Apr 2016 14:29:41 +0100 Subject: Avoid division by zero --- src/NXP/Classes/Token/TokenDivision.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/NXP') diff --git a/src/NXP/Classes/Token/TokenDivision.php b/src/NXP/Classes/Token/TokenDivision.php index 479a4ec..7e55640 100644 --- a/src/NXP/Classes/Token/TokenDivision.php +++ b/src/NXP/Classes/Token/TokenDivision.php @@ -47,7 +47,7 @@ class TokenDivision extends AbstractOperator { $op2 = array_pop($stack); $op1 = array_pop($stack); - $result = $op1->getValue() / $op2->getValue(); + $result = $op2->getValue() > 0 ? $op1->getValue() / $op2->getValue() : 0; return new TokenNumber($result); } -- cgit v1.2.3