void executeExponentialDblDbl(Executer &executer) { auto y = executer.topDbl(); executer.pop(); auto x = executer.topDbl(); calculatePowerDblDbl(executer, x, y); }
void executeSubtractDblDbl(Executer &executer) { auto rhs = executer.topDbl(); executer.pop(); auto result = executer.topDbl() - rhs; checkDoubleOverflow(executer, result); executer.setTop(result); }
void executeDivideDblInt(Executer &executer) { auto rhs = static_cast<double>(popIntegerDivisor(executer)); auto lhs = executer.topDbl(); auto result = lhs / rhs; executer.setTop(result); }
inline double popDoubleDivisor(Executer &executer) { auto rhs = executer.topDbl(); checkDivideByZero(executer, rhs); executer.pop(); return rhs; }
void executeMultiplyIntDbl(Executer &executer) { auto rhs = executer.topDbl(); executer.pop(); auto lhs = executer.topIntAsDbl(); multiplyAndCheckResult(executer, lhs, rhs); }
void executeExponentialDblInt(Executer &executer) { auto y = executer.topInt(); executer.pop(); auto x = executer.topDbl(); executer.setTop(PowerDblInt{executer, x, y}()); }
void executeAbsDbl(Executer &executer) { auto argument = executer.topDbl(); if (argument < 0) { executer.setTop(-argument); } }
void executeIntegerDivide(Executer &executer) { auto rhs = popDoubleDivisor(executer); auto lhs = executer.topDbl(); auto result = lhs / rhs; checkIntegerOverflow(executer, result); executer.setTopIntFromDouble(result); }
void executeSqr(Executer &executer) { auto argument = executer.topDbl(); if (argument < 0) { throw RunError {"square root of negative number", executer.currentOffset()}; } executer.setTop(std::sqrt(argument)); }
void executeLog(Executer &executer) { auto argument = executer.topDbl(); if (argument <= 0) { throw RunError {"logarithm of non-positive number", executer.currentOffset()}; } executer.setTop(std::log(argument)); }
void executeSubtractDblInt(Executer &executer) { auto rhs = executer.topIntAsDbl(); executer.pop(); executer.setTop(executer.topDbl() - rhs); }
void executeCvtInt(Executer &executer) { auto operand = std::round(executer.topDbl()); checkIntegerOverflow(executer, operand); executer.setTopIntFromDouble(operand); }
void executeExp(Executer &executer) { auto result = std::exp(executer.topDbl()); checkForOverflow(executer, result); executer.setTop(result); }
inline void doDoubleMultiply(Executer &executer, double rhs) { executer.pop(); auto lhs = executer.topDbl(); multiplyAndCheckResult(executer, lhs, rhs); }
void executeAtn(Executer &executer) { executer.setTop(std::atan(executer.topDbl())); }
void executeCos(Executer &executer) { executer.setTop(std::cos(executer.topDbl())); }
void executeSin(Executer &executer) { executer.setTop(std::sin(executer.topDbl())); }
void executeNegateDbl(Executer &executer) { executer.setTop(-executer.topDbl()); }
void executeFrac(Executer &executer) { auto argument = executer.topDbl(); executer.setTop(argument - std::trunc(argument)); }
void executeDivideDblDbl(Executer &executer) { auto rhs = popDoubleDivisor(executer); auto lhs = executer.topDbl(); divideAndCheckResult(executer, lhs, rhs); }
void executeInt(Executer &executer) { executer.setTop(std::floor(executer.topDbl())); }
void executeModuloDblDbl(Executer &executer) { auto rhs = popDoubleDivisor(executer); auto lhs = executer.topDbl(); executer.setTop(std::fmod(lhs, rhs)); }
void executeAddDblInt(Executer &executer) { auto rhs = executer.topIntAsDbl(); executer.pop(); executer.setTop(executer.topDbl() + rhs); }
void executeModuloDblInt(Executer &executer) { auto rhs = static_cast<double>(popIntegerDivisor(executer)); auto lhs = executer.topDbl(); executer.setTop(std::fmod(lhs, rhs)); }
void executeFix(Executer &executer) { executer.setTop(std::trunc(executer.topDbl())); }
void executeMultiplyDblDbl(Executer &executer) { auto rhs = executer.topDbl(); doDoubleMultiply(executer, rhs); }