inline void executeSgn(Executer &executer) { auto argument = executer.top<T>(); if (argument > T{0}) { executer.setTop(T{1}); } else if (argument < 0.0) { executer.setTop(T{-1}); } else { executer.setTop(T{0}); } }
void executeExponentialIntInt(Executer &executer) { auto y = executer.topInt(); executer.pop(); auto x = executer.topInt(); executer.setTop(PowerIntInt{executer, x, y}()); }
void executeAbsDbl(Executer &executer) { auto argument = executer.topDbl(); if (argument < 0) { executer.setTop(-argument); } }
void executeDivideDblInt(Executer &executer) { auto rhs = static_cast<double>(popIntegerDivisor(executer)); auto lhs = executer.topDbl(); auto result = lhs / rhs; executer.setTop(result); }
void executeCatStrStr(Executer &executer) { auto rhs = executer.topStr(); executer.pop(); executer.setTop(*executer.topStr()); *executer.topTmpStr() += *rhs; }
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 executeSubtractDblDbl(Executer &executer) { auto rhs = executer.topDbl(); executer.pop(); auto result = executer.topDbl() - rhs; checkDoubleOverflow(executer, result); executer.setTop(result); }
void executeAbsInt(Executer &executer) { auto argument = executer.topInt(); if (argument < 0) { checkNegativeIntegerOverflow(executer, argument); executer.setTop(-argument); } }
void executeRndInt(Executer &executer) { auto argument = executer.topInt(); if (argument <= 0) { throw RunError {"random function on zero or negative number", executer.currentOffset()}; } executer.setTop(executer.getRandomNumber(argument)); }
void executeCatStrTmp(Executer &executer) { auto rhs_result = executer.topTmpStr(); executer.pop(); auto lhs_rhs = std::string{*executer.topStr()}; std::swap(lhs_rhs, *rhs_result); executer.setTop(rhs_result); *executer.topTmpStr() += lhs_rhs; }
void executeSubtractDblInt(Executer &executer) { auto rhs = executer.topIntAsDbl(); executer.pop(); executer.setTop(executer.topDbl() - rhs); }
void executeFrac(Executer &executer) { auto argument = executer.topDbl(); executer.setTop(argument - std::trunc(argument)); }
void executeExp(Executer &executer) { auto result = std::exp(executer.topDbl()); checkForOverflow(executer, result); executer.setTop(result); }
void executeCvtDbl(Executer &executer) { executer.setTop(executer.topIntAsDbl()); }
void executeAtn(Executer &executer) { executer.setTop(std::atan(executer.topDbl())); }
inline void calculatePowerDblDbl(Executer &executer, double x, double y) { auto result = std::pow(x, y); validatePowerResult(x, result, executer); executer.setTop(result); }
void executeSin(Executer &executer) { executer.setTop(std::sin(executer.topDbl())); }
void executeModuloIntInt(Executer &executer) { auto rhs = popIntegerDivisor(executer); executer.setTop(executer.topInt() % rhs); }
void executeModuloDblInt(Executer &executer) { auto rhs = static_cast<double>(popIntegerDivisor(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 executeModuloIntDbl(Executer &executer) { auto rhs = popDoubleDivisor(executer); auto lhs = executer.topIntAsDbl(); executer.setTop(std::fmod(lhs, rhs)); }
void executeInt(Executer &executer) { executer.setTop(std::floor(executer.topDbl())); }
void executeXor(Executer &executer) { auto rhs = executer.topInt(); executer.pop(); executer.setTop(executer.topInt() ^ rhs); }
void executeAnd(Executer &executer) { auto rhs = executer.topInt(); executer.pop(); executer.setTop(executer.topInt() & rhs); }
void executeNot(Executer &executer) { executer.setTop(~executer.topInt()); }
void executeEqv(Executer &executer) { auto rhs = executer.topInt(); executer.pop(); executer.setTop(~(executer.topInt() ^ rhs)); }
void executeCos(Executer &executer) { executer.setTop(std::cos(executer.topDbl())); }
void executeFix(Executer &executer) { executer.setTop(std::trunc(executer.topDbl())); }
void executeImp(Executer &executer) { auto rhs = executer.topInt(); executer.pop(); executer.setTop(~executer.topInt() | rhs); }