From 4f9b5406fef114bb1bbcb47ada8054bf7b6c2fcc Mon Sep 17 00:00:00 2001 From: dehnert Date: Tue, 3 Feb 2015 15:13:36 +0100 Subject: [PATCH] Fixed simplification of unary expressions. Former-commit-id: 6644bf571756e5b580cad674436112fd4aa6b579 --- .../UnaryNumericalFunctionExpression.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/storage/expressions/UnaryNumericalFunctionExpression.cpp b/src/storage/expressions/UnaryNumericalFunctionExpression.cpp index adec2af05..6e2a13ae0 100644 --- a/src/storage/expressions/UnaryNumericalFunctionExpression.cpp +++ b/src/storage/expressions/UnaryNumericalFunctionExpression.cpp @@ -61,15 +61,21 @@ namespace storm { } boost::variant result; - switch (this->getOperatorType()) { - case OperatorType::Minus: result = -(operandSimplified->hasIntegerType() ? boost::get(operandEvaluation) : boost::get(operandEvaluation)); break; - case OperatorType::Floor: result = std::floor(operandSimplified->hasIntegerType() ? boost::get(operandEvaluation) : boost::get(operandEvaluation)); break; - case OperatorType::Ceil: result = std::ceil(operandSimplified->hasIntegerType() ? boost::get(operandEvaluation) : boost::get(operandEvaluation)); break; - } - - if (result.type() == typeid(int_fast64_t)) { - return std::shared_ptr(new IntegerLiteralExpression(this->getManager(), boost::get(result))); + if (operandSimplified->hasIntegerType()) { + int_fast64_t value = 0; + switch (this->getOperatorType()) { + case OperatorType::Minus: value = -boost::get(operandEvaluation); break; + case OperatorType::Floor: value = std::floor(boost::get(operandEvaluation)); break; + case OperatorType::Ceil: value = std::ceil(boost::get(operandEvaluation)); break; + } + return std::shared_ptr(new IntegerLiteralExpression(this->getManager(), value)); } else { + double value = 0; + switch (this->getOperatorType()) { + case OperatorType::Minus: value = -boost::get(operandEvaluation); break; + case OperatorType::Floor: value = std::floor(boost::get(operandEvaluation)); break; + case OperatorType::Ceil: value = std::ceil(boost::get(operandEvaluation)); break; + } return std::shared_ptr(new DoubleLiteralExpression(this->getManager(), boost::get(result))); } }