Basic Arithmetic Operations

Learn how to evaluate basic arithmetic expressions with addition, subtraction, multiplication, and division. Understand operator precedence and parentheses grouping.

Arithmetic

Detailed Explanation

Basic Arithmetic in Math Expressions

The four fundamental arithmetic operations form the foundation of every mathematical expression:

  • Addition (+): Combines two values. 5 + 3 equals 8.
  • Subtraction (-): Finds the difference. 10 - 4 equals 6.
  • Multiplication (*): Scales a value. 6 * 7 equals 42.
  • Division (/): Splits a value. 20 / 4 equals 5.

Operator Precedence (PEMDAS/BODMAS)

When an expression contains multiple operators, the parser follows standard mathematical precedence:

  1. Parentheses ( ) are evaluated first.
  2. Exponentiation ^ comes next.
  3. Multiplication, Division, Modulo * / % are evaluated left to right.
  4. Addition, Subtraction + - are evaluated last, left to right.

Example

2 + 3 * 4 = 14      (not 20, because * binds tighter than +)
(2 + 3) * 4 = 20    (parentheses override precedence)
10 - 2 * 3 + 1 = 5  (2*3=6, then 10-6+1=5)

Modulo Operator

The % operator returns the remainder after integer division:

17 % 5 = 2    (17 divided by 5 is 3 remainder 2)
10 % 3 = 1
100 % 7 = 2

This is useful for determining whether a number is even (n % 2 == 0) or for cyclic indexing in programming.

Division by Zero

Dividing by zero is undefined in mathematics. The evaluator catches this and returns a clear error message rather than producing Infinity or NaN.

Use Case

A student verifying homework answers by checking multi-step arithmetic expressions against the evaluator, or a developer quickly computing values during debugging.

Try It — Math Expression Evaluator

Open full tool