Math Expression Evaluator

Evaluate mathematical expressions safely without eval(). Supports hex, binary, octal literals, functions like sqrt and sin, with results in multiple formats.

Your data never leaves your browser Available via MCP

Enter a math expression and click Calculate

Supports: +, -, *, /, %, ^ (power), hex (0xFF), binary (0b1010), octal (0o777)
Functions: abs, sqrt, log2, log10, sin, cos, tan, ceil, floor, round, min, max, pow
Constants: PI, E

How to Use

  1. Type a math expression: (2^10) * 1024, log2(65536), 0xFF * 3.
  2. Click Calculate or press Enter.
  3. Results appear in decimal, hex, binary, octal, and scientific notation.
  4. Copy any result with the Copy button.

Operator Reference

  • + - * / — basic arithmetic
  • % — modulo (remainder)
  • ^ or ** — exponentiation (right-associative)
  • () — grouping and function calls

Developer-Useful Calculations

  • 2^32 — max unsigned 32-bit integer (4,294,967,296)
  • 2^53 - 1 — JavaScript MAX_SAFE_INTEGER
  • 0xFF * 0xFF — hex multiplication
  • log2(65536) — how many bits for 65536 values (16)
  • 1024 * 1024 * 1024 — bytes in a GiB

Related Tools

Convert number bases with the Number Base Converter. Calculate file sizes with the Byte Calculator. Convert ASCII/hex/binary with the ASCII Converter. Calculate Unix permissions with the chmod Calculator.

Frequently Asked Questions

Is this safe? Does it use eval()?
No, this tool does NOT use eval() or Function(). It uses a custom recursive descent parser that only understands mathematical operations. It cannot execute arbitrary code.
What number formats are supported?
Decimal (42, 3.14), hexadecimal (0xFF), binary (0b1010), octal (0o777), and scientific notation (1.5e3). Results are shown in all applicable formats.
What functions are available?
abs, ceil, floor, round, sqrt, cbrt, log (natural), ln, log2, log10, sin, cos, tan, asin, acos, atan, min, max, pow, sign, trunc.
What constants are available?
PI (3.14159...), E (2.71828...), and Infinity.

Use this tool from AI agents. The CodeTidy MCP Server lets Claude, Cursor, and other AI agents use this tool and 46 others directly. One command: npx @codetidy/mcp

Drop file to load