#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Note: The C++ based format in uCalc, used here, works only in Windows as of this writing. // This is because uCalc is currently compiled with C++ 20 to get the right balance // between maximum compatibility across platforms and access to modern C++ functionality. // *std::format* is technically part of C++ 20, but it's not universally implemented in // different compilers using the C++ 20 compilation directive. // Rule 1: Format Doubles as currency with two decimal places. auto doubleType = uc.DataTypeOf(BuiltInType::Float_Double); uc.Format("Result = '$' + Format('{:.2f}', double(Result))", doubleType); // Rule 2: Center-align strings in a 15-character field padded with '-'. auto strType = uc.DataTypeOf(BuiltInType::String); uc.Format("Result = Format('{:-^15}', Result)", strType); cout << "Price: " << uc.EvalStr("199.999") << endl; cout << "Discount: " << uc.EvalStr("7.5") << endl; cout << "Label: " << uc.EvalStr("'Summary'") << endl; }