Skip to content

Latest commit

 

History

History
3 lines (2 loc) · 970 Bytes

File metadata and controls

3 lines (2 loc) · 970 Bytes

Arithmetic-Formula

We introduce FormulaArithmetic, a lightweight JavaScript library that enables dynamic, client-side evaluation of complex arithmetic expressions in web applications. Unlike native eval() approaches, FormulaArithmetic safely parses and executes formulas containing both standard operators ( +, -, *, /, %, ^ ) and Excel-style functions (ADD, SUBTRACT, MULTIPLY, DIVIDE, MOD, POWER), including nested and variadic calls. Its architecture combines an iterative function-expansion preprocessor, a linear-time tokenizer, Dijkstra’s Shunting-Yard algorithm for operator precedence (BODMAS/PEMDAS), and a stack-based RPN evaluator—yielding robust performance (O(F·L) worst-case for F nested functions over an expression of length L) without external dependencies. FormulaArithmetic integrates seamlessly as a standalone web resource or ES module, empowering form designers to deliver spreadsheet-like formula capabilities directly within the browser.