diff --git a/src/storm/storage/expressions/UnaryNumericalFunctionExpression.cpp b/src/storm/storage/expressions/UnaryNumericalFunctionExpression.cpp index 3ed20d7b6..770c7b9f1 100644 --- a/src/storm/storage/expressions/UnaryNumericalFunctionExpression.cpp +++ b/src/storm/storage/expressions/UnaryNumericalFunctionExpression.cpp @@ -74,6 +74,7 @@ namespace storm { operandEvaluation = operandSimplified->evaluateAsRational(); } + bool rationalToInteger = this->getOperatorType() == OperatorType::Floor || this->getOperatorType() == OperatorType::Ceil; if (operandSimplified->hasIntegerType()) { int_fast64_t value = 0; switch (this->getOperatorType()) { @@ -82,6 +83,15 @@ namespace storm { case OperatorType::Ceil: value = std::ceil(boost::get(operandEvaluation)); break; } return std::shared_ptr(new IntegerLiteralExpression(this->getManager(), value)); + } else if (rationalToInteger) { + int_fast64_t value = 0; + switch (this->getOperatorType()) { + case OperatorType::Floor: value = storm::utility::convertNumber(storm::RationalNumber(carl::floor(boost::get(operandEvaluation)))); break; + case OperatorType::Ceil: value = storm::utility::convertNumber(storm::RationalNumber(carl::ceil(boost::get(operandEvaluation)))); break; + default: + STORM_LOG_ASSERT(false, "Unexpected rational to integer conversion."); + } + return std::shared_ptr(new IntegerLiteralExpression(this->getManager(), value)); } else { storm::RationalNumber value = storm::utility::zero(); switch (this->getOperatorType()) { diff --git a/src/storm/utility/constants.cpp b/src/storm/utility/constants.cpp index 6086f1bf9..6c0d1c814 100644 --- a/src/storm/utility/constants.cpp +++ b/src/storm/utility/constants.cpp @@ -324,7 +324,12 @@ namespace storm { uint_fast64_t convertNumber(ClnRationalNumber const& number) { return carl::toInt(number); } - + + template<> + int_fast64_t convertNumber(ClnRationalNumber const& number) { + return carl::toInt(number); + } + template<> ClnRationalNumber convertNumber(double const& number) { return carl::rationalize(number); @@ -516,7 +521,12 @@ namespace storm { uint_fast64_t convertNumber(GmpRationalNumber const& number){ return carl::toInt(number); } - + + template<> + int_fast64_t convertNumber(GmpRationalNumber const& number){ + return carl::toInt(number); + } + template<> GmpRationalNumber convertNumber(double const& number){ return carl::rationalize(number);