Skip to content
OEWER Tools
How-To

How a Scientific Calculator Works Out an Expression

4 min readBy OEWER Team

How the order of operations, brackets, powers, functions and degrees or radians decide the answer to a typed expression, with examples to check.

In this article
  1. The order of operations
  2. Powers and minus signs
  3. Functions
  4. Degrees or radians
  5. Factorials and percentages
  6. Why 0.1 + 0.2 looks odd on some calculators
  7. Safe by design
  8. Sources

Type 2 + 3 × 4 into a calculator and the answer is 14, not 20. That is because calculators follow an agreed order of operations. A scientific calculator adds functions such as sine, logarithms and square roots, and it has to apply the same rules to those. This guide explains the rules, with examples that you can type into the Scientific Calculator on this site, which lists every step of its working under the answer.

The order of operations

Wikipedia sets out the standard convention. Work out anything in brackets first. Then handle exponents (powers) and roots. Then multiplication and division, from left to right. Finally addition and subtraction, also from left to right. For 2 + 3 × 4 the multiplication comes first: 3 × 4 = 12, then 2 + 12 = 14. With brackets, (2 + 3) × 4 gives 5 × 4 = 20. Operations of the same rank run from left to right, so 10 − 4 − 3 is (10 − 4) − 3 = 3, and 100 ÷ 4 ÷ 5 is 25 ÷ 5 = 5.

Powers and minus signs

Powers have two features that surprise people. First, they group from the right: 2 ^ 3 ^ 2 means 2 ^ (3 ^ 2) = 2 ^ 9 = 512, not (2 ^ 3) ^ 2 = 64. Second, a minus sign in front of a number is applied after the power, so −2 ^ 2 is −(2 ^ 2) = −4. To square a negative number, put brackets around it: (−2) ^ 2 = 4. A negative exponent means a reciprocal, so 2 ^ −1 = 1 ÷ 2 = 0.5.

Functions

A function takes a value in brackets and returns a result. For example sqrt(16) = 4, ln(e) = 1 (the natural logarithm, base e), log(1000) = 3 (the base-10 logarithm), and abs(−7.5) = 7.5. The brackets are important: they show where the value of the function begins and ends. The functions are computed before the operators around them, so 2 × sqrt(16) + 1 = 2 × 4 + 1 = 9. Two-value functions such as root(8, 3), which is the cube root of 8, take two numbers separated by a comma.

Degrees or radians

Angles can be measured in degrees, where a full turn is 360, or in radians, where a full turn is 2π, about 6.2832. The sine of an angle depends on which one the calculator expects. In degrees, sin(30) = 0.5. In radians, sin(30) is about −0.988, because 30 radians is a very different angle. To convert, multiply degrees by π ÷ 180. If you want sin of 30 degrees while in radian mode, type sin(30 × pi ÷ 180). The inverse functions such as asin return an angle in the chosen unit, so asin(1) is 90 in degrees and about 1.5708 in radians.

Factorials and percentages

The factorial of a whole number n, written n!, is the product of all whole numbers from 1 to n, so 5! = 5 × 4 × 3 × 2 × 1 = 120, and 0! is defined as 1. Factorials grow very quickly: 170! is the largest one that fits in the number format used by browsers, which is why the calculator stops there. A percentage sign divides by 100, so 50% = 0.5 and 200 × 10% = 20.

Why 0.1 + 0.2 looks odd on some calculators

Computers store most decimals in binary floating-point format, and a number like 0.1 cannot be stored exactly. The addition 0.1 + 0.2 produces 0.30000000000000004 in many programming languages. MDN notes that the Math functions work on this same kind of number. To avoid showing such noise, this calculator rounds answers to 12 significant digits, so 0.1 + 0.2 appears as 0.3. The rounding is only for display; the working lines also use the rounded values.

  • Use brackets when in doubt: they never hurt and make the order obvious
  • Two things side by side are multiplied, so 2(3 + 4) is 14 and 3pi is about 9.4248
  • Check degree or radian mode before using sin, cos or tan
  • Square roots of negative numbers and division by zero are reported as errors, not as a made-up answer

Safe by design

The calculator reads what you type with its own small parser. It understands only numbers, the operators and the functions listed above, so it never runs the text as program code. Anything else is rejected with a plain message. That keeps the tool safe and means nothing you type leaves your device.

Sources

This article was written with AI assistance. How we research and check our articles.

Share

Email

Keep reading