Cadmeo

Scientific Calculator

Supports + - * / % ^ ! brackets, pi, e, and sin cos tan asin acos atan sinh cosh tanh ln log sqrt abs exp floor ceil round.

Result

68

Parsed as: 16 sqrt 2 8 ^ 4 / +

The scientific calculator evaluates a whole expression rather than one button press at a time, supporting 17 functions, powers, factorials and brackets. It shows how your expression was parsed, so a result that looks wrong can be traced to a precedence assumption rather than guessed at.

How it works

The expression is tokenised, converted to reverse Polish notation by the shunting-yard algorithm, then evaluated. That is deliberately not eval(). Eval would execute arbitrary JavaScript from the input box and would accept things that are not mathematics at all.

  • Operators: + − * / % ^ and postfix ! for factorial.
  • Functions: sin cos tan asin acos atan sinh cosh tanh ln log sqrt abs exp floor ceil round.
  • Constants: pi and e.
  • Precedence: functions, then ^ (right-associative), then * / %, then + −. Brackets override all of it.

Exponentiation is right-associative, so 2^3^2 is 2^(3^2) = 512, not (2^3)^2 = 64. The parsed form shown under the result makes which one you got explicit.

Examples

Precedence in action

Expression

sqrt(16) + 2^8 / 4

Result

68

4 + (256 / 4). The power binds tighter than the division, which binds tighter than the addition.

Right-associative powers

Expression

2^3^2

Result

512

Evaluated as 2^(3^2) = 2^9. A calculator that gave 64 would be treating ^ as left-associative, which contradicts standard mathematical notation.

Degrees mode

Expression

sin(30)

Angle mode

Degrees

Result

0.5

In radians the same expression gives −0.988. Getting this wrong is the single most common cause of a wrong trigonometry answer.

Frequently asked questions

Why does 2^3^2 give 512 and not 64?

Because exponentiation is right-associative in standard mathematical notation, so it evaluates as 2^(3^2) = 2^9 = 512. Some calculators get this wrong. The parsed form shown beneath the result tells you exactly which grouping was used.

Why not just use eval?

Because eval executes arbitrary JavaScript from the input box. Even with no server involved that is unacceptable, and it would also accept expressions that are not mathematics. A typo could silently do something unexpected instead of reporting an error.

How do I switch between degrees and radians?

With the angle mode selector. It affects sin, cos and tan on input and asin, acos and atan on output. sin(30) is 0.5 in degrees and −0.988 in radians, so the setting matters more than any other on the page.

What is the largest factorial it handles?

170!, which is about 7.26 × 10^306. 171! exceeds the largest number JavaScript can represent and returns infinity. Non-integer and negative factorials are reported as errors rather than approximated with the gamma function.