Skip to content
QA Knowledge Hub

Test cases for a calculator

Updated 2026-11-13 · 6 min read

A calculator looks simple until you ask how it handles precedence, decimals, overflow and percent. These 34 cases cover arithmetic, precision, boundaries, errors, functions, UI and speed.

Assumes a standard (not scientific) calculator app for web and mobile with digits, the four operators, decimal point, equals, percent, sign change, square root, C, CE, backspace and memory keys (M+, M−, MR, MC), with a 12-digit display. Where calculators genuinely differ, the expected result says "as specified": find out the rule before you run the case.

How to answer in an interview

Ask first: basic or scientific, physical or app, how many digits, does it follow operator precedence or calculate as you go, how does it round, what does percent do, and which locales does it support? Then group: basic arithmetic, decimals and precision, boundaries, errors, functions, and UI and performance. Mention precedence and floating point early; they show you know where calculators actually break.

Why 0.1 + 0.2 is a real test

Any app that does arithmetic with binary floating point numbers can show tiny errors. This is what JavaScript does without rounding (run with Node v24.22.2):

console.log(0.1 + 0.2);
console.log(Number((0.1 + 0.2).toFixed(10)));
console.log(5 / 0, 0 / 0);
console.log((1234567.5).toLocaleString("en-IN"));
console.log((1234567.5).toLocaleString("en-US"));
0.30000000000000004
0.3
Infinity NaN
12,34,567.5
1,234,567.5

So C09 catches a display that is not rounded, C19 and C20 catch an app that prints Infinity or NaN instead of an error message, and C32 checks Indian digit grouping.

Basic arithmetic

IDCategoryTest caseExpected result
C01Functional2 + 3 =5
C02Functional9 − 12 =−3
C03Functional6 × 7 =42
C04Functional8 ÷ 2 =4
C05Functional7 ÷ 2 =3.5
C06Functional2 + 3 × 4 =14 with precedence or 20 with immediate execution, as specified
C07Functional5 + 2 = =9 if repeating the last operation is specified; otherwise stays 7
C08Functional10 − 4 + 2 =8

Decimals and precision

IDCategoryTest caseExpected result
C09Functional0.1 + 0.2 =0.3, not 0.30000000000000004
C10Functional1 ÷ 3 =0.33333333333 filling the display, rounded as specified
C11Functional2 ÷ 3 =Last digit rounded (…667) or cut off (…666), as specified
C12NegativeType 1 . . 2Second decimal point ignored; shows 1.2
C13FunctionalType 0 0 7Shows 7, not 007

Boundaries

IDCategoryTest caseExpected result
C14BoundaryType 13 digits on a 12-digit display13th digit ignored
C15Boundary999999999999 + 1 =Overflow handled as specified (error or scientific notation); never a wrong number
C16Boundary0.0000001 ÷ 1000000 =Scientific notation or 0, as specified; no garbage digits
C17Functional−5 × −5 = (using the sign key)25
C18Boundary99999999 × 99999999 =Exact result if it fits, otherwise the specified overflow behaviour

Errors

IDCategoryTest caseExpected result
C19Negative5 ÷ 0 =Clear message such as "Cannot divide by zero"; app does not crash; C clears it
C20Negative0 ÷ 0 =Same error handling; never shows NaN
C21NegativeSquare root of −9Error message on a standard calculator
C22Negative5 + × 3 =Last operator pressed wins: 15
C23Negative5 + =Behaviour as specified (5 or 10); no crash

Functions

IDCategoryTest caseExpected result
C24Functional200 + 10 % =Result as the spec defines percent (often 220); document the rule
C25Functional12 + 34, press CE, type 5, =CE clears only 34; result 17. C clears everything
C26FunctionalType 123 and press backspaceShows 12
C27Functional10 M+, 3 M−, MR, then MC and MRMR shows 7; after MC, MR shows 0 and the memory indicator goes off
C28FunctionalType 8 and press the sign key twice−8, then 8

UI, compatibility and performance

IDCategoryTest caseExpected result
C29CompatibilityUse a physical keyboard: digits, + − * /, Enter, Esc, BackspaceEach key does the same as its on-screen button
C30FunctionalCopy a result; paste a number; paste textResult copies; the number pastes; text is rejected
C31UIProduce a 12-digit result on a narrow phone screenFully visible or shrunk to fit; never cut off silently
C32FunctionalShow 1234567.5 with the locale set to India and to the US12,34,567.5 and 1,234,567.5, if locale grouping is supported
C33CompatibilityRotate the phone mid-calculationCurrent number and pending operation are kept
C34PerformancePress keys as fast as possibleEvery press registered once, in order, without lag

What to prioritise

Correctness first (C01 to C11), then errors (C19 to C23), because a calculator that shows a wrong number is worse than one that shows an error. In interviews, the common mistake is to state C06 or C24 as if there were only one right answer. Say that you would ask, then give both possibilities.

Downloads

Quick answers

Is 2 + 3 × 4 equal to 14 or 20 on a calculator?

It depends on the calculator. One that evaluates the whole expression with precedence gives 14; a simple immediate-execution calculator applies each operator as you press it and gives 20. Ask which behaviour is specified; both can be correct.

Why test 0.1 + 0.2?

Many apps store numbers as binary floating point, where 0.1 + 0.2 is not exactly 0.3. If the app shows 0.30000000000000004, it is not rounding its display, and money calculations built the same way may be wrong too.

What does the percent key do?

It varies between calculators. On many basic calculators 200 + 10 % gives 220 (10 percent of 200 added), while others treat 10 % as 0.1. Write the expected result from the spec, not from your own phone.

Want a project you can show in interviews?

The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.