https://github.com/elldritch/simple-calculator
A simple JavaScript calculator that evaluates arbitrary mathematical expressions. Intended as a demonstration.
https://github.com/elldritch/simple-calculator
Last synced: about 1 year ago
JSON representation
A simple JavaScript calculator that evaluates arbitrary mathematical expressions. Intended as a demonstration.
- Host: GitHub
- URL: https://github.com/elldritch/simple-calculator
- Owner: elldritch
- Created: 2013-08-10T02:46:14.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-08-11T05:55:10.000Z (almost 13 years ago)
- Last Synced: 2025-02-24T10:49:29.917Z (over 1 year ago)
- Language: CSS
- Size: 363 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# simple-calculator.js
It's a simple calculator, in case you couldn't tell. It supports arbitrary evaluation of mathematical expressions while checking for operator precedence. Supported operations include braces, unary negation, exponentiation, multiplication, and addition.
## Usage
```javascript
var calc = require('simple-calculator');
calc('(5 + 5) / 24^-8');
calc(' (5 + 5 / 24)^-8', true); // Verbose reporting.
```
The first argument is a string expression, the second is `true` or `false` for verbosity, the third is the number of decimal places to round (defaults to 5).