|| | ___ ___ || |
|| _|__/ _\_______/ _\_______|| _|
||(___( (________( (_________||((_)
|| | \___/ \___/ || |
|| _|________/ _\_____________|| _|
||(_________( (_______________||((_)
|| | \___/ || |
A maths expression parser and calculator.
Converts infix to postfix expressions and calculates the result.
'arithmio' is available as an npm package:
$ npm install arithmio
or as a RESTful API.
evaluate(infixExpression: string): number
calculates the result of infixExpression.
convertInfixToPostfix(expression: string): string
returns a postfix string of expression
calculate(postfixExpression: string): number
calculates the result of postfixExpression
var evaluate = require("arithmio").evaluate;
/* es6 import
import { evaluate } from 'arithmio';
*/
const infixExpression = "1 + 1";
const result = evaluate(infixExpression); // 2
+
Adds the first operand to the second operand
-
Subtracts the first operand from the second operand.
*
Multiplies the first operand by the second operand.
/
Divides the first operand by the second operand.
^
Raises the first operand to the power of the second operand e.g. '10^6'.
Shorthand to perform common arithmetic operations.
SQRT(n)
returns the square-root of n.
Shorthand to access mathmatical constants.
PI
returns the value of PI.
SUM(x, y, z...)
Returns the sum of all operands passed.
- Logical operators
- Additional helper functions