[{"data":1,"prerenderedAt":38},["ShallowReactive",2],{"$fojCgz3kzdvmVtchWbIevQhf6QpwjrRd8wzkaF0DO0QM":3},{"slug":4,"title":5,"description":6,"date":7,"tags":8,"tools":13,"draft":15,"html":16,"toc":17,"minutes":37},"percentage-questions-explained","Six Percentage Questions and the Formula Behind Each One","Percent of, what percent, change, the whole from a part, adding VAT and taking it back out, plus how the calculator reads 1,250, 12,5 and Arabic digits.","2026-09-28",[9,10,11,12],"math","calculators","typescript","arabic",[14],"percentage-calculator",false,"\u003Cp>A receipt says 114 pounds, VAT included, and you want the price before VAT. Most people take 14% off and get 98.04. The real answer is 100. That gap is why I built the \u003Ca href=\"\u002Fpercentage-calculator\">percentage calculator\u003C\u002Fa> the way I did, with six questions side by side and the formula printed under every answer.\u003C\u002Fp>\n\u003Cp>The arithmetic in each question is one line. Picking the right one is where people go wrong, and so is typing the number in a way a calculator understands. This article covers both.\u003C\u002Fp>\n\u003Ch2 id=\"the-six-questions\">The six questions\u003C\u002Fh2>\n\u003Cp>Most everyday percentage questions fit one of these. The page shows them all at once, filled with examples, so you can spot the one that sounds like yours.\u003C\u002Fp>\n\u003Cdiv class=\"table-wrap\">\u003Ctable>\u003Cthead>\n\u003Ctr>\n\u003Cth>Question\u003C\u002Fth>\n\u003Cth>Example\u003C\u002Fth>\n\u003Cth>Formula\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>What is p% of y?\u003C\u002Ftd>\n\u003Ctd>15% of 200\u003C\u002Ftd>\n\u003Ctd>y × p ÷ 100 = 30\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>x is what percent of y?\u003C\u002Ftd>\n\u003Ctd>425 out of 500\u003C\u002Ftd>\n\u003Ctd>x ÷ y × 100 = 85%\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Change from a to b\u003C\u002Ftd>\n\u003Ctd>80 to 100\u003C\u002Ftd>\n\u003Ctd>(b − a) ÷ a × 100 = +25%\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>x is p% of what?\u003C\u002Ftd>\n\u003Ctd>30 is 15% of …\u003C\u002Ftd>\n\u003Ctd>x ÷ p × 100 = 200\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>y plus or minus p%\u003C\u002Ftd>\n\u003Ctd>250 plus 14%\u003C\u002Ftd>\n\u003Ctd>y × (1 + p ÷ 100) = 285\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Amount before p% was added\u003C\u002Ftd>\n\u003Ctd>114 includes 14%\u003C\u002Ftd>\n\u003Ctd>total ÷ (1 + p ÷ 100) = 100\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\u003C\u002Fdiv>\u003Cp>Each one is a small function in \u003Ccode>utils\u002Fpercent.ts\u003C\u002Fcode> that returns either a value or an error message. The errors are the cases with no answer. “x is what percent of 0” divides by zero, and so does a percentage change that starts at 0. For that one the message says why: any change from 0 is infinite.\u003C\u002Fp>\n\u003Cp>One detail in the change formula: it divides by the absolute value of the starting number. Going from −50 to −25 is a rise, and the tests expect +50%, not −50%.\u003C\u002Fp>\n\u003Ch2 id=\"percent-and-percentage-points\">Percent and percentage points\u003C\u002Fh2>\n\u003Cp>When a rate goes from 10% to 12%, two different numbers describe it:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>It rose by \u003Cstrong>2 percentage points\u003C\u002Fstrong>. That’s the plain difference, 12 − 10.\u003C\u002Fli>\n\u003Cli>It rose by \u003Cstrong>20 percent\u003C\u002Fstrong>. That’s the change formula applied to the rate itself, (12 − 10) ÷ 10 × 100.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>Both are correct. They answer different questions, and they’re easy to mix up. If you put 10 and 12 in the “change” row, the calculator gives 20%, because that’s the question the row asks. For percentage points you only need subtraction.\u003C\u002Fp>\n\u003Cp>Two more traps belong here because they come from the same idea. A percentage always applies to some base, and the base moves:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>20% off and then another 10% off is 28% off, not 30%. The second discount applies to the reduced price.\u003C\u002Fli>\n\u003Cli>A price that goes up 50% and then down 50% ends at 75% of where it started. The tests check this one.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"taking-vat-back-out\">Taking VAT back out\u003C\u002Fh2>\n\u003Cp>This is the question from the receipt. When VAT was added, the price before VAT was multiplied by 1.14. To undo it, you divide by 1.14:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">export\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> const\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> removePercent\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#b35309;--shiki-dark:#FFAB70\">total\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> number\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#b35309;--shiki-dark:#FFAB70\">p\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> number\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">)\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> Result\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> =>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (p \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">===\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> -\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">100\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> ?\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> fail\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'The percentage can’t be −100.'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> ok\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(total \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> p \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 100\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">)))\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>114 ÷ 1.14 = 100. Subtracting 14% instead means multiplying by 0.86, which gives 98.04. The two methods disagree because the 14% was calculated on 100, and subtracting 14% calculates it on 114.\u003C\u002Fp>\n\u003Cp>The row also shows the VAT part on its own (“The 14% part: 14”), which is what you need for an expense claim. The only percentage it refuses is −100, which would divide by zero.\u003C\u002Fp>\n\u003Cp>The same function works for any amount that had a percentage added on top: a service charge, a tip, a markup. The page’s FAQ lists some standard VAT rates (14% in Egypt, 15% in Saudi Arabia, 5% in the UAE, 20% in the UK). Reduced rates exist for some goods, so check your invoice when it matters.\u003C\u002Fp>\n\u003Ch2 id=\"reading-numbers-the-way-people-type-them\">Reading numbers the way people type them\u003C\u002Fh2>\n\u003Cp>People don’t all type numbers the same way. Some write 1,250 for one thousand two hundred fifty. Some write 12,5 for twelve and a half, because a comma is their decimal separator. On an Arabic keyboard, the same number may arrive as ١٢٥٠٫٥. A calculator that only accepts \u003Ccode>1250.5\u003C\u002Fcode> turns all of these into errors.\u003C\u002Fp>\n\u003Cp>\u003Ccode>parseNumber\u003C\u002Fcode> handles them in a fixed order. First it replaces Arabic-Indic and Persian digits with Latin ones, turns the Arabic decimal separator \u003Ccode>٫\u003C\u002Fcode> into a dot, and removes the separators that only group thousands (the Arabic \u003Ccode>٬\u003C\u002Fcode>, spaces and apostrophes). The digit conversion uses a small trick: the code points for ٠ to ٩ (U+0660 to U+0669) and for ۰ to ۹ (U+06F0 to U+06F9) both end in the digit’s value, so keeping the low four bits gives the digit.\u003C\u002Fp>\n\u003Cp>Then comes the hard part, the comma:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">  const\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> thousands\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">^\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#DBEDFF\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">?\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\\d\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">{1,3}\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#DBEDFF\">(,\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\\d\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">{3}\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#DBEDFF\">)\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#DBEDFF\">%\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">?$\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">test\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(s)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">  s \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> !\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">s.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">includes\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'.'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">&#x26;&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> !\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">thousands \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">&#x26;&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (s.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">match\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#DBEDFF\">,\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">g\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">??\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> []).\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">length\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> ===\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> ?\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> s.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">replace\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">','\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'.'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> s.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">replace\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#DBEDFF\">,\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">g\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">''\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>A comma is read as a thousands separator when the number looks like one: one to three digits, then groups of exactly three (1,250 or 1,250,000). It’s read as a decimal comma when it’s the only comma, there’s no dot, and the number doesn’t fit the thousands pattern (12,5 or 0,75). In every other case the commas are dropped.\u003C\u002Fp>\n\u003Cp>That rule has one honest blind spot. “1,250” could be one and a quarter in a country that writes decimals with a comma, and the parser reads it as 1250. I chose that because three digits after a single comma is much more likely to be a thousands group in the prices and marks people type here. The formula under each answer prints the numbers as they were read, so 12,5 shows up as 12.5, and an answer a thousand times too big is hard to miss. In the same spirit, a dot is always a decimal point, so “1.250” is 1.25.\u003C\u002Fp>\n\u003Cp>After the comma, the parser drops a trailing \u003Ccode>%\u003C\u002Fcode>, a leading \u003Ccode>+\u003C\u002Fcode>, and turns the Unicode minus sign \u003Ccode>−\u003C\u002Fcode> into a hyphen. Whatever is left must look like a plain number (scientific notation like \u003Ccode>1e3\u003C\u002Fcode> is allowed), or the row shows “Enter numbers only, like 12.5 or 1,250.”\u003C\u002Fp>\n\u003Ch2 id=\"hiding-floating-point-noise\">Hiding floating-point noise\u003C\u002Fh2>\n\u003Cp>JavaScript numbers are binary floating point, so some simple decimals can’t be stored exactly. In the browser console:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Ccode>0.1 + 0.2\u003C\u002Fcode> is \u003Ccode>0.30000000000000004\u003C\u002Fcode>\u003C\u002Fli>\n\u003Cli>\u003Ccode>1.005 * 100\u003C\u002Fcode> is \u003Ccode>100.49999999999999\u003C\u002Fcode>\u003C\u002Fli>\n\u003Cli>\u003Ccode>114 \u002F 1.14\u003C\u002Fcode> is \u003Ccode>100.00000000000001\u003C\u002Fcode>\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>That last one is the VAT example. Showing “100.00000000000001” on a receipt question would make the calculator look broken, even though the error is in the 17th significant digit. The fix is one line:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">export\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> const\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> clean\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#b35309;--shiki-dark:#FFAB70\">n\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">:\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> number\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#cb2431;--shiki-dark:#F97583\">=>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> Number\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(n.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">toPrecision\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">12\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">))\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Rounding to 12 significant digits throws away the noise at the end and keeps far more precision than any price, mark or salary needs. Every result goes through \u003Ccode>clean\u003C\u002Fcode> before it’s returned, and the final grade and GPA calculators on the site reuse the same function. For display, \u003Ccode>format\u003C\u002Fcode> adds thousands separators and limits the decimals (up to 6, or 4 in the rows that answer with a percentage or an adjusted amount), so 1,234,567.891 reads as a number.\u003C\u002Fp>\n\u003Cp>I didn’t use a decimal library. For six formulas with one or two operations each, rounding the result was enough, and the tests pin the cases above.\u003C\u002Fp>\n\u003Ch2 id=\"try-it\">Try it\u003C\u002Fh2>\n\u003Cp>The \u003Ca href=\"\u002Fpercentage-calculator\">percentage calculator\u003C\u002Fa> has all six questions on one page, each with its own formula, and accepts commas, decimal commas and Arabic digits. More tools like it are in \u003Ca href=\"\u002Fcalculators\">calculators\u003C\u002Fa>.\u003C\u002Fp>\n",[18,22,25,28,31,34],{"id":19,"text":20,"level":21},"the-six-questions","The six questions",2,{"id":23,"text":24,"level":21},"percent-and-percentage-points","Percent and percentage points",{"id":26,"text":27,"level":21},"taking-vat-back-out","Taking VAT back out",{"id":29,"text":30,"level":21},"reading-numbers-the-way-people-type-them","Reading numbers the way people type them",{"id":32,"text":33,"level":21},"hiding-floating-point-noise","Hiding floating-point noise",{"id":35,"text":36,"level":21},"try-it","Try it",5,1792325805305]