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.
-
Notifications
You must be signed in to change notification settings - Fork 0
ParamVarunReddy/Arithmetic-Formula
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published