首页 通用效率工具内容详情

Basic Calculator: Parentheses, Percent and Chain Operations, Done Right - Results as you type, tape you can copy

2026-11-17 3 访客
Basic Calculator: Parentheses, Percent and Chain Operations, Done Right

站点名称:Basic Calculator: Parentheses, Percent and Chain Operations, Done Right

所属分类:通用效率工具

官方网址:https://www.9314.cn/tools/basic-calculator/en/

SEO查询: 爱站网 站长工具

进入网站

站点介绍

Basic Calculator: Parentheses, Percent and Chain Operations, Done Right

Two design failures make phone calculators maddening: 2+3*4 comes out 20 (precedence lost), and one wrong digit means all-clear and start over. After explaining "multiplication before addition" to a family member over the phone for the third time one evening, I built this page: standard precedence, results as you type, and a backspace that actually backs up.

The short version

  • Standard precedence: parentheses, then multiplication and division, then addition and subtraction. 2+3*4=14, (2+3)*4=20 - not a character of ambiguity.
  • Live preview: every keystroke refreshes the result; unclosed parentheses are auto-closed for the preview, no need to wait for equals.
  • Chained operations: press an operator after a result and it keeps calculating. 3+5, equals, then *2 gives 16.
  • Percent with add/subtract semantics: 200+10%=220 (add a tenth), 200-10%=180 (ten percent off), and a lone 50% is 0.5.
  • Paper tape: every calculation lands on the tape, clicks back into the expression, and copies as text; the parser is hand-written recursive descent with zero dynamic execution.

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 tokenizes against a whitelist grammar first (numbers, operators, parentheses, percent - nothing else recognized), then computes by precedence. An expression here can only ever be math.

What the keyboard does

The physical keyboard works fully: digits, operators + - * /, parentheses, percent, scientific-notation e, Enter for the result, Backspace to delete, Esc to clear. On phones the on-screen keys stand 52px tall - reachable with a thumb.

FAQ

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.

中文版:https://www.9314.cn/tools/basic-calculator/

 暂无评论,快来抢沙发吧~

发布评论