9314JIUsi
Utilities · Browser-local arithmetic

Basic Calculator: Parentheses, Percent, Chained Math

2+3*4 should be 14, not 20. This calculator computes with standard precedence: parentheses first, then multiplication and division, then addition and subtraction. Percent, sign flip, backspace and all-clear are all on the keyboard - and your physical keyboard works too, with results as you type. The engine is a hand-written recursive-descent parser; zero dynamic code execution anywhere.

 
0
Hand-written parser · zero dynamic execution

Everything you type is calculated in this page's memory only - nothing is uploaded and there is no account. The paper-tape history on the right stays in this browser; switching devices or clearing site data loses it. Clear my data in the footer removes it.

参数与边界
InputArithmetic expressions: numbers (decimals included), + − × ÷, parentheses, % (after a number), ± (negative), x10ⁿ (scientific notation); keyboard or on-screen keys
OutputLive preview as you type; = commits the result to the paper tape; plain-language errors
Key parametersNo options; tape capped at 50 entries (oldest rolls off); ?expr=2%2B3*4 deep-links an expression
ProcessingRecursive-descent computing in your browser (hand-written parser, zero dynamic execution); expressions never stored or uploaded
LimitsExpressions up to 500 characters; numbers within ±1e±308; tape 50 entries
Known limitsNo scientific functions or fractions; implicit multiplication (2(3+4)) must be written 2*(3+4); dividing by 0 reports an error; two operators in a row keeps only the last

How to use it

Click the keypad or just type on your physical keyboard. 0-9 enter digits, + - * / are operators, ( ) parentheses, % percent. Enter or = commits the result to the tape, Backspace deletes a character, Esc clears everything. After a result, pressing an operator keeps calculating from it.

Precedence and percent

The parser descends through the grammar: expression → additive terms → multiplicative factors → atoms (parentheses, numbers, percent). So 2+3*4 = 14 and (2+3)*4 = 20; 200+10% = 220 (adding 10% is multiplying by 1.1), and a lone 50% is just 0.5.

Why nothing gets executed dynamically

Feeding user input straight into a dynamic execution call hands the page's privileges to whoever types - the textbook XSS entrance. This calculator's parser is hand-written: it tokenizes against a whitelist grammar, then computes by precedence. An expression here can only ever be math; nothing else executes.

Related tools

Which operations does the calculator support?

Add, subtract, multiply and divide, parentheses to change precedence, a percent sign that divides the preceding number by 100, a sign-flip key, decimals, and chained operations (3+5 then pressing *2 keeps calculating from the result). Scientific functions, implicit multiplication (2(3+4) must be written 2*(3+4)) and fractions are not supported.

What does 2+3*4 equal?

14. The parser follows standard precedence: multiplication and division before addition and subtraction, parentheses first. To add before multiplying, write (2+3)*4, which gives 20.

How does the percent key work?

50% means 50/100 = 0.5, so 200*50% = 100 and 200+10% = 220 (adding 10% is multiplying by 1.1). Put the percent sign right after a number; 50%% is not supported.

Is my arithmetic uploaded anywhere?

No. All calculation happens in this device's browser - there is no upload endpoint and the page works offline. The paper-tape history lives in this browser's localStorage; Clear my data in the footer removes it in one click.