80 int_fast64_t firstOperandEvaluation = this->
getFirstOperand()->evaluateAsInt(valuation);
81 int_fast64_t secondOperandEvaluation = this->
getSecondOperand()->evaluateAsInt(valuation);
82 int_fast64_t result = 0;
85 result = firstOperandEvaluation + secondOperandEvaluation;
88 result = firstOperandEvaluation - secondOperandEvaluation;
91 result = firstOperandEvaluation * secondOperandEvaluation;
94 result = firstOperandEvaluation / secondOperandEvaluation;
97 result = std::min(firstOperandEvaluation, secondOperandEvaluation);
100 result = std::max(firstOperandEvaluation, secondOperandEvaluation);
103 result =
static_cast<int_fast64_t
>(std::pow(firstOperandEvaluation, secondOperandEvaluation));
106 result = firstOperandEvaluation % secondOperandEvaluation;
109 result =
logHelper(firstOperandEvaluation, secondOperandEvaluation);
118 double firstOperandEvaluation = this->
getFirstOperand()->evaluateAsDouble(valuation);
119 double secondOperandEvaluation = this->
getSecondOperand()->evaluateAsDouble(valuation);
123 result = firstOperandEvaluation + secondOperandEvaluation;
126 result = firstOperandEvaluation - secondOperandEvaluation;
129 result = firstOperandEvaluation * secondOperandEvaluation;
132 result = firstOperandEvaluation / secondOperandEvaluation;
135 result = std::min(firstOperandEvaluation, secondOperandEvaluation);
138 result = std::max(firstOperandEvaluation, secondOperandEvaluation);
141 result = std::pow(firstOperandEvaluation, secondOperandEvaluation);
144 result = std::fmod(firstOperandEvaluation, secondOperandEvaluation);
147 result =
logHelper(firstOperandEvaluation, secondOperandEvaluation);
154 std::shared_ptr<BaseExpression const> firstOperandSimplified = this->
getFirstOperand()->simplify();
155 std::shared_ptr<BaseExpression const> secondOperandSimplified = this->
getSecondOperand()->simplify();
157 if (firstOperandSimplified->isLiteral() && secondOperandSimplified->isLiteral()) {
159 int_fast64_t firstOperandEvaluation = firstOperandSimplified->evaluateAsInt();
160 int_fast64_t secondOperandEvaluation = secondOperandSimplified->evaluateAsInt();
161 std::optional<int_fast64_t> newValue;
164 newValue = firstOperandEvaluation + secondOperandEvaluation;
167 newValue = firstOperandEvaluation - secondOperandEvaluation;
170 newValue = firstOperandEvaluation * secondOperandEvaluation;
173 newValue = std::min(firstOperandEvaluation, secondOperandEvaluation);
176 newValue = std::max(firstOperandEvaluation, secondOperandEvaluation);
179 if (secondOperandEvaluation >= 0) {
182 newValue =
static_cast<int_fast64_t
>(std::pow(firstOperandEvaluation, secondOperandEvaluation));
186 newValue = firstOperandEvaluation % secondOperandEvaluation;
192 if (firstOperandEvaluation % secondOperandEvaluation == 0) {
196 newValue = firstOperandEvaluation / secondOperandEvaluation;
204 storm::RationalNumber firstOperandEvaluation = firstOperandSimplified->evaluateAsRational();
205 storm::RationalNumber secondOperandEvaluation = secondOperandSimplified->evaluateAsRational();
206 std::optional<storm::RationalNumber> newValue;
209 newValue = firstOperandEvaluation + secondOperandEvaluation;
212 newValue = firstOperandEvaluation - secondOperandEvaluation;
215 newValue = firstOperandEvaluation * secondOperandEvaluation;
218 newValue = std::min(firstOperandEvaluation, secondOperandEvaluation);
221 newValue = std::max(firstOperandEvaluation, secondOperandEvaluation);
224 newValue = firstOperandEvaluation / secondOperandEvaluation;
227 if (carl::isInteger(secondOperandEvaluation)) {
228 auto exponent = carl::toInt<carl::sint>(secondOperandEvaluation);
230 newValue = carl::pow(firstOperandEvaluation, exponent);
232 storm::RationalNumber power = carl::pow(firstOperandEvaluation, -exponent);
233 newValue = storm::utility::one<storm::RationalNumber>() / power;
239 if (carl::isInteger(firstOperandEvaluation) && carl::isInteger(secondOperandEvaluation)) {
254 if (firstOperandSimplified.get() == this->getFirstOperand().get() && secondOperandSimplified.get() == this->getSecondOperand().get()) {
255 return this->shared_from_this();
BinaryNumericalFunctionExpression(ExpressionManager const &manager, Type const &type, std::shared_ptr< BaseExpression const > const &firstOperand, std::shared_ptr< BaseExpression const > const &secondOperand, OperatorType operatorType)
Constructs a binary numerical function expression with the given return type, operands and operator.