站点介绍

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.
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.
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.
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.
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.
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.
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/
评论列表 (0条)