Long Subtraction Calculator
Type the two numbers and the stage sets the problem out the way it is written on paper, then works it column by column. 5002 - 1348 is the case people get stuck on: the units cannot take 8 from 2 and the two columns to the left are 0s, so the borrow travels all the way to the thousands and the top row is rewritten 4 9 9 12, which is 3 borrows and a difference of 3654. The same chain runs across a longer gap, and 1000 - 1 rewrites all three zeros to give 999. Decimals are padded before anything is subtracted, so 1.2 - 0.35 is worked as 1.20 - 0.35 and gives 0.85. Every step is integer arithmetic on the digit strings themselves rather than on floating point numbers, so 0.3 - 0.1 is 0.2 here and not 0.19999999999999998. When the second number is the larger one, 0 - 3 is worked as 3 - 0 and printed as -3, with no borrow invented from a column that had nothing to give. Up to 200 digits in each box: a minus sign, the decimal point and thousands separators are accepted and none of them count towards the 200.
5002 - 1348 ----
4 9 9 12 - 1 3 4 8 ------------ 3 6 5 4 5002 - 1348 = 3654 borrow chain thousands 5 to 4, hundreds 0 to 9, tens 0 to 9, units 2 to 12
- Difference
- 3654
- Borrows
- 3
- Digits
- 4
- Sign
- Positive
3 borrows in the working, the longest running 3 columns left across 2 zeros.
The two numbers
Signs, decimal points and thousands separators are all fine: 1,000 and 1000 are read the same way, and the shorter number is padded with zeros so the places line up. Up to 200 digits in each box.
Order matters here in a way it does not in addition: 5002 - 1348 is 3654, and the same two numbers the other way round give -3654. Swap turns one into the other, and the columns are worked from the larger number either way, so no borrow is ever taken from a column with nothing in it.
Worked examples
Each one runs through the same function as your own numbers. Copy takes the subtraction and its difference.
Common questions
- How do you do long subtraction with borrowing?
- Line the two numbers up by place, work from the right, and when the digit on top is smaller than the one under it take ten from the column to its left. The page draws exactly that: in 5002 - 1348 the units cannot take 8 from 2, so a borrow arrives and the units column reads 12, which leaves 4. Each column is written under the rule in turn and the difference is 3654. The readout counts the borrows, 3 of them here, and the line under the columns names every digit the borrow rewrote.
- What happens when you have to borrow from a zero?
- A 0 has nothing to give, so the borrow carries on to the next column left, and every 0 it passes turns into a 9. That is the whole of 5002 - 1348: the thousands 5 becomes 4, both 0s become 9, and the units 2 becomes 12, which is why the top row reads 4 9 9 12 while the sum is being worked. 1000 - 1 is the same move across a longer run, where all three zeros are rewritten and the answer is 999. The chain is printed under the columns in the order a hand writes it, starting with the column that gave.
- How do you subtract decimals in columns?
- Pad the shorter number with zeros so both have the same number of decimal places, subtract as though the point were not there, and bring the point straight down. 1.2 - 0.35 is worked as 1.20 - 0.35: the hundredths borrow from the tenths, the tenths borrow from the units, and the answer is 0.85 in 2 borrows. The left pane shows the padded form, so the zeros the page added are visible rather than assumed.
- What if the number you are subtracting is the bigger one?
- Then the difference is negative and the columns are worked the other way round. 0 - 3 is done as 3 - 0 and printed as -3: nothing is borrowed from a column that has nothing to give, and the borrow count stays at 0. The working says which way round the columns ran, and the Sign cell in the readout reads Negative. The column method as it is taught assumes the top number is the larger one, so the page names the swap it made rather than inventing a borrow.
- Does this calculator round the answer?
- No, and it has nothing to round. Every value is a digit string and every step is arithmetic on digits between 0 and 9, so no floating point number is ever created. A browser asked for 0.3 - 0.1 in its own arithmetic answers 0.19999999999999998, while these columns give exactly 0.2. The same holds at the other end of the scale, where 1 followed by 199 zeros, less 1, comes back as 199 nines with every digit correct.
- Can it subtract negative numbers?
- Yes. The columns work on the digits and the sign is settled outside them. When the two signs match the digits are subtracted, so -5 minus -3 is -2. When the signs differ, taking a negative away is the same as adding, so 5 - (-3) becomes 5 + 3 and the working switches to an addition with carries, which the readout counts in place of borrows. A difference of zero is never written with a minus sign.
- How many digits can it subtract?
- Up to 200 in each box, the decimal point and the minus sign aside. Past that the page says how many digits it counted and asks you to shorten the number or split the subtraction into parts, rather than quietly working on a different number. At the cap the arithmetic is still exact: 200 nines less 1 is 199 nines and an 8, and the borrow chain is drawn for all of it.
- Why does the top row of the subtraction change?
- Those are the borrows, written where a hand would cross a digit out and write the new one above it. A column that gave ten away is one smaller, a 0 the borrow passed through is now a 9, and the column that needed the ten is now ten bigger, which is why 5002 reads 4 9 9 12 as it is worked. The problem as it was set out stays on the left pane, so the before and the after sit side by side.
Exact decimal arithmetic on the digit strings you type rather than on a floating point number, which is why 0.3 minus 0.1 is 0.2 here and not 0.19999999999999998. When the subtrahend is the larger number the page subtracts the other way and prints the minus sign, instead of borrowing from a column that has nothing to give.