Skip to content
AndyNoob edited this page Jan 22, 2024 · 4 revisions

Welcome to the math-expressions wiki! This page will be a quick guide on the syntax required by the parser.

Usage

MathExpression.parse("1 + 1 - 3 + x").setVariable("x", 9).evaluate(); // output: 8

Syntax

Numbers

While floating-point notation is not supported, any real number is supported:

  1. 1, 10, -1024
  2. 0.2454, -3.04593, 9.3333

Please do note that numbers are still subject to floating-point inaccuracy.

Operators

Currently, these operators are supported (and executed in order of):

  1. Power (^)
  2. Multiply, divide (* & /)
  3. Add, subtract (+ & -)

Parentheses

Opening parentheses are paired with the closest closing parentheses.

Clone this wiki locally