81 int_fast64_t firstOperandEvaluation = this->
getFirstOperand()->evaluateAsInt(valuation);
82 int_fast64_t secondOperandEvaluation = this->
getSecondOperand()->evaluateAsInt(valuation);
83 int_fast64_t result = 0;
86 result = firstOperandEvaluation + secondOperandEvaluation;
89 result = firstOperandEvaluation - secondOperandEvaluation;
92 result = firstOperandEvaluation * secondOperandEvaluation;
95 result = firstOperandEvaluation / secondOperandEvaluation;
98 result = std::min(firstOperandEvaluation, secondOperandEvaluation);
101 result = std::max(firstOperandEvaluation, secondOperandEvaluation);
104 result =
static_cast<int_fast64_t
>(std::pow(firstOperandEvaluation, secondOperandEvaluation));
107 result = firstOperandEvaluation % secondOperandEvaluation;
110 result =
logHelper(firstOperandEvaluation, secondOperandEvaluation);
119 double firstOperandEvaluation = this->
getFirstOperand()->evaluateAsDouble(valuation);
120 double secondOperandEvaluation = this->
getSecondOperand()->evaluateAsDouble(valuation);
124 result = firstOperandEvaluation + secondOperandEvaluation;
127 result = firstOperandEvaluation - secondOperandEvaluation;
130 result = firstOperandEvaluation * secondOperandEvaluation;
133 result = firstOperandEvaluation / secondOperandEvaluation;
136 result = std::min(firstOperandEvaluation, secondOperandEvaluation);
139 result = std::max(firstOperandEvaluation, secondOperandEvaluation);
142 result = std::pow(firstOperandEvaluation, secondOperandEvaluation);
145 result = std::fmod(firstOperandEvaluation, secondOperandEvaluation);
148 result =
logHelper(firstOperandEvaluation, secondOperandEvaluation);
155 std::shared_ptr<BaseExpression const> firstOperandSimplified = this->
getFirstOperand()->simplify();
156 std::shared_ptr<BaseExpression const> secondOperandSimplified = this->
getSecondOperand()->simplify();
158 if (firstOperandSimplified->isLiteral() && secondOperandSimplified->isLiteral()) {
160 int_fast64_t firstOperandEvaluation = firstOperandSimplified->evaluateAsInt();
161 int_fast64_t secondOperandEvaluation = secondOperandSimplified->evaluateAsInt();
162 std::optional<int_fast64_t> newValue;
165 newValue = firstOperandEvaluation + secondOperandEvaluation;
168 newValue = firstOperandEvaluation - secondOperandEvaluation;
171 newValue = firstOperandEvaluation * secondOperandEvaluation;
174 newValue = std::min(firstOperandEvaluation, secondOperandEvaluation);
177 newValue = std::max(firstOperandEvaluation, secondOperandEvaluation);
180 if (secondOperandEvaluation >= 0) {
183 newValue =
static_cast<int_fast64_t
>(std::pow(firstOperandEvaluation, secondOperandEvaluation));
187 newValue = firstOperandEvaluation % secondOperandEvaluation;
193 if (firstOperandEvaluation % secondOperandEvaluation == 0) {
197 newValue = firstOperandEvaluation / secondOperandEvaluation;
205 storm::RationalNumber firstOperandEvaluation = firstOperandSimplified->evaluateAsRational();
206 storm::RationalNumber secondOperandEvaluation = secondOperandSimplified->evaluateAsRational();
207 std::optional<storm::RationalNumber> newValue;
210 newValue = firstOperandEvaluation + secondOperandEvaluation;
213 newValue = firstOperandEvaluation - secondOperandEvaluation;
216 newValue = firstOperandEvaluation * secondOperandEvaluation;
219 newValue = std::min(firstOperandEvaluation, secondOperandEvaluation);
222 newValue = std::max(firstOperandEvaluation, secondOperandEvaluation);
225 newValue = firstOperandEvaluation / secondOperandEvaluation;
228 if (carl::isInteger(secondOperandEvaluation)) {
229 auto exponent = carl::toInt<carl::sint>(secondOperandEvaluation);
231 newValue = carl::pow(firstOperandEvaluation, exponent);
233 storm::RationalNumber power = carl::pow(firstOperandEvaluation, -exponent);
234 newValue = storm::utility::one<storm::RationalNumber>() / power;
240 if (carl::isInteger(firstOperandEvaluation) && carl::isInteger(secondOperandEvaluation)) {
255 if (firstOperandSimplified.get() == this->getFirstOperand().get() && secondOperandSimplified.get() == this->getSecondOperand().get()) {
256 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.