#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; cout << uc.Error().FloatingPointErrorsToTrap() << endl; cout << uc.EvalStr("1/0") << endl; cout << uc.EvalStr("0/0") << endl; cout << uc.EvalStr("5*10^308") << endl; cout << uc.EvalStr("10^-308/10000") << endl; cout << "--- Raise Div-by-0 ---" << endl; uc.Error().FloatingPointErrorsToTrap((int)ErrorCode::FloatDivisionByZero); cout << uc.Error().FloatingPointErrorsToTrap() << endl; cout << uc.EvalStr("1/0") << endl; cout << uc.EvalStr("0/0") << endl; cout << uc.EvalStr("5*10^308") << endl; cout << uc.EvalStr("10^-308/10000") << endl; cout << "--- Raise overflow ---" << endl; uc.Error().FloatingPointErrorsToTrap((int)ErrorCode::FloatOverflow); cout << uc.Error().FloatingPointErrorsToTrap() << endl; cout << uc.EvalStr("1/0") << endl; cout << uc.EvalStr("0/0") << endl; cout << uc.EvalStr("5*10^308") << endl; cout << uc.EvalStr("10^-308/10000") << endl; cout << "--- Raise invalid & underflow ---" << endl; uc.Error().SetFloatingPointErrorsToTrap(ErrorCode::FloatInvalid, ErrorCode::FloatUnderflow); cout << uc.Error().FloatingPointErrorsToTrap() << endl; // ErrorCode::FloatInvalid + ErrorCode::FloatUnderflow cout << uc.EvalStr("1/0") << endl; cout << uc.EvalStr("0/0") << endl; cout << uc.EvalStr("5*10^308") << endl; cout << uc.EvalStr("10^-308/10000") << endl; }