Math Expression Evaluator
WebEverything runs locally in your browser — nothing is uploaded
One expression per line, one result per line. Supported: + - * / % and ^ for powers, parentheses and unary signs, the constants pi and e, and the functions sqrt, abs, round, floor, ceil, exp, log, log2, log10, min, max and pow. ⚠️ This tool does not use eval, and that is not fussiness. An eval-based version runs whatever is in the box inside the current page: fetch("/x") really fires, location="https://…" really navigates, and this page holds other data. The usual patch is a regex that only allows digits and operators, and those regexes are famously leaky. So the parser, precedence and evaluation are written out here (shunting-yard into postfix, then evaluate), and anything beyond the listed characters is rejected outright. Two things worth knowing up front. The caret means power, not bitwise xor, and it is right-associative, so 2^3^2 is 512 rather than 64. And the trig functions convert both their input and their output, because changing only one of those makes sin(asin(0.5)) stop being 0.5.
Features
- Arithmetic, remainder, powers and parentheses, with unary signs (-3, 2 * -3 and 2^-1 all work)
- The caret is a power and right-associative: 2^3^2 is 512. For bitwise xor use the bitwise tool
- The constants pi and e, and the functions sqrt, abs, round, floor, ceil, exp, log, log2, log10, min, max, pow
- Angles switch between radians and degrees, converting input and output together
- Define variables such as a=3 and use them in expressions; later definitions can see earlier ones
- Round to a chosen number of decimals while the full precision stays visible on its own line
- One expression per line, so a whole column can be computed at once
- The evaluator is hand-written with no eval, and any name outside the constant and function tables is rejected
- Everything runs in your browser; the expressions never leave it
How to use
- Paste one expression per line
- Switch to degrees if you need it, and define variables if you want to reuse intermediate values
- Set a decimal count if you want rounding; the exact value is shown separately
- Copy a single result or the whole list
FAQ
- Why is avoiding eval worth mentioning?
- Because eval is the easy way to build this tool, and it treats the input as code in the current page: fetch("/x") sends a request, location="https://…" navigates away, and constructor.constructor("…")() walks around most blacklists. The common mitigation, a regex that allows only digits and operators, is not sound either, and it fails silently. So the tokenizer, precedence and evaluation are all written out here. The cost is that arbitrary functions cannot be supported; the benefit is that nothing in the input can execute except the numbers, operators, parentheses and listed function names.
- Does 2^-1 work, with the minus on the right of the power?
- Yes. Unary minus has the highest precedence, so 2^-1 is read as 2^(-1) and gives 0.5. Some implementations rewrite a leading minus as multiply by -1, which falls apart in exactly this position, so a dedicated unary operator is used here instead.
- How do variables work?
- One definition per line in the variables box, such as a=3. The right side can be an expression (b=a*3), and later definitions can use earlier ones, so a=2 on one line makes b=a*3 valid on the next. Variable names are case-insensitive, but constants win: defining pi=3 does not shadow the real π.
- Why does 1/0 not just give me Infinity?
- Because Infinity is almost always a sign that something is wrong rather than the answer you wanted. Division by zero, the square root of a negative and a log fed zero or a negative all produce it, for three unrelated reasons. Handing back Infinity leaves you to guess which one happened, so all three are reported together as an infinite result, with the common causes listed.
Related tools
Bitwise Calculator
ConvertTen bitwise operations: AND, OR, XOR, XNOR, NAND, NOR, NOT, shifts and bit reversal, with decimal, binary and hex for every result.
Radix Calculator
ConvertDo arithmetic in binary, octal, decimal or hex with exact BigInt maths and no wraparound; division also reports the remainder.
Fraction Calculator
ConvertSimplify fractions, find the greatest common divisor and least common multiple, convert decimals to fractions and do fraction arithmetic.
URL Parser
WebParse a URL into scheme, host, port, path, query parameters and fragment, with each parameter shown raw and decoded. Runs entirely in your browser.
User-Agent Parser
WebParse a user agent into browser, version, OS, device type and engine, and see which rules matched. Pattern matching only. Runs entirely in your browser.
HTTP Status Codes
WebLook up an HTTP status code for its meaning, 1xx–5xx class, typical uses and common traps. Runs entirely in your browser.