Integer Calculator
Test cases replayed : 4 of 4 match · Methodology · No outside source listed
Do arithmetic with negative numbers: pick the operation, enter two whole numbers and see the result, its sign and, for division, the quotient and remainder.
Result
Result
Integer quotient (division only)
- Remainder, 0 or more (division only)
- Sign of the result
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- First integer: enter a number.
- Operation: choose Add (a + b), Subtract (a − b), Multiply (a × b) or Divide (a ÷ b).
- Second integer: enter a number.
- Read the result: Result; the panel also shows Integer quotient (division only), Remainder, 0 or more (division only) and Sign of the result.
How this calculator works
Adding a negative number is the same as subtracting its absolute value, and subtracting a negative number is the same as adding its absolute value: a − (−b) = a + b.
Multiplying or dividing two numbers with the same sign gives a positive result; with different signs, a negative result. Division by zero is undefined, so the calculator shows a dash.
Integer division follows the division algorithm taught in number theory (Euclidean division): a = b × q + r with the remainder r between 0 and |b| − 1. For −17 ÷ 5 the quotient is −4 and the remainder 3, because 5 × (−4) + 3 = −17. Some programming languages truncate toward zero instead and give −3 remainder −2.
Worked example
| First integer | -12 |
|---|---|
| Operation | Subtract (a − b) |
| Second integer | -5 |
| Result | -7 |
|---|---|
| Sign of the result | Negative |
Frequently asked questions
What is −12 minus −5?
−12 − (−5) = −12 + 5 = −7.
Is a negative times a negative positive?
Yes. (−6) × (−4) = 24, while (−6) × 4 = −24.
Why is the remainder never negative here?
Euclidean division keeps 0 ≤ r < |b|, so every integer has exactly one quotient and remainder for a given divisor.