From 4f9b5406fef114bb1bbcb47ada8054bf7b6c2fcc Mon Sep 17 00:00:00 2001
From: dehnert <dehnert@cs.rwth-aachen.de>
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<int_fast64_t, double> result;
-                switch (this->getOperatorType()) {
-                    case OperatorType::Minus: result = -(operandSimplified->hasIntegerType() ? boost::get<int_fast64_t>(operandEvaluation) : boost::get<double>(operandEvaluation)); break;
-                    case OperatorType::Floor: result = std::floor(operandSimplified->hasIntegerType() ? boost::get<int_fast64_t>(operandEvaluation) : boost::get<double>(operandEvaluation)); break;
-                    case OperatorType::Ceil: result = std::ceil(operandSimplified->hasIntegerType() ? boost::get<int_fast64_t>(operandEvaluation) : boost::get<double>(operandEvaluation)); break;
-                }
-                
-                if (result.type() == typeid(int_fast64_t)) {
-                    return std::shared_ptr<BaseExpression>(new IntegerLiteralExpression(this->getManager(), boost::get<int_fast64_t>(result)));
+                if (operandSimplified->hasIntegerType()) {
+                    int_fast64_t value = 0;
+                    switch (this->getOperatorType()) {
+                        case OperatorType::Minus: value = -boost::get<int_fast64_t>(operandEvaluation); break;
+                        case OperatorType::Floor: value = std::floor(boost::get<int_fast64_t>(operandEvaluation)); break;
+                        case OperatorType::Ceil: value = std::ceil(boost::get<int_fast64_t>(operandEvaluation)); break;
+                    }
+                    return std::shared_ptr<BaseExpression>(new IntegerLiteralExpression(this->getManager(), value));
                 } else {
+                    double value = 0;
+                    switch (this->getOperatorType()) {
+                        case OperatorType::Minus: value = -boost::get<double>(operandEvaluation); break;
+                        case OperatorType::Floor: value = std::floor(boost::get<double>(operandEvaluation)); break;
+                        case OperatorType::Ceil: value = std::ceil(boost::get<double>(operandEvaluation)); break;
+                    }
                     return std::shared_ptr<BaseExpression>(new DoubleLiteralExpression(this->getManager(), boost::get<double>(result)));
                 }
             }