A bank balance of −₹2,000 means you owe money. A temperature of −5 °C is five degrees below freezing. A profit of −₹50,000 is a loss. A model's error of −3 means it predicted 3 too high. Negative numbers are everywhere in data, and many people who "can't do maths" simply never got comfortable with them.
This lesson fixes that. Using the number line and everyday examples, it explains how to compare, add, subtract, multiply and divide negative numbers, why "two negatives make a positive", and where negatives appear in data science.
What you need first: the number line from types of numbers, and the order of operations.
Key terms
- Negative number: a number less than zero, written with a minus sign, like −4.
- Positive number: a number greater than zero. The plus sign is usually left out: 4 means +4.
- Sign: whether a number is positive or negative.
- Opposite: the number the same distance from zero on the other side. The opposite of 4 is −4.
- Absolute value: the distance from zero, ignoring the sign. Both 4 and −4 have absolute value 4, written |−4| = 4.
Think of the number line
On the number line, zero is in the middle, positives go right and negatives go left. Two ideas make everything else easy:
- Adding a positive number moves you right.
- Subtracting a positive number moves you left.
A thermometer turned on its side is a number line. If it's 3 °C and the temperature falls 5 degrees, you move 5 steps left: 3 − 5 = −2 °C.
Comparing negative numbers
Further left is always smaller. So:
- −2 is bigger than −7, because it's further right. (A temperature of −2 °C is warmer than −7 °C.)
- Any negative number is smaller than any positive number: −100 < 1.
- The "bigger-looking" negative is the smaller one: −50 < −5.
print(-2 > -7)
print(-50 < -5)
print(sorted([3, -1, -8, 0, 5, -3]))
print(max(-4, -9), min(-4, -9))
True
True
[-8, -3, -1, 0, 3, 5]
-4 -9
Adding and subtracting
Adding a negative number moves left
Adding a negative is the same as subtracting: 5 + (−3) = 5 − 3 = 2.
Example: you have ₹500 and a −₹300 charge appears on your account. Your balance is 500 + (−300) = ₹200.
Subtracting a negative number moves right
Subtracting a negative is the same as adding: 5 − (−3) = 5 + 3 = 8.
This one surprises people, so here's an everyday version. A debt is a negative amount of money. If someone takes away a ₹3,000 debt you owed (subtracts −3,000), you're ₹3,000 better off. Taking away a negative adds.
Another way to see it: subtraction measures the gap between two numbers. The gap from −3 up to 5 on the number line is 8 steps, so 5 − (−3) = 8. That's why temperature differences work: from −3 °C to 5 °C, the temperature rose 8 degrees.
Starting below zero
- −4 + 6 = 2: start at −4, move 6 right.
- −4 − 6 = −10: start at −4, move 6 further left.
- −4 + (−6) = −10: adding a negative moves left too.
The two rules to remember
| You see | It becomes | Example |
|---|---|---|
| + (−) | − | 7 + (−2) = 7 − 2 = 5 |
| − (−) | + | 7 − (−2) = 7 + 2 = 9 |
Multiplying and dividing
For multiplication and division, work out the size of the answer normally, then decide the sign with these rules:
| Signs | Answer | Example |
|---|---|---|
| positive × positive | positive | 3 × 4 = 12 |
| negative × positive | negative | −3 × 4 = −12 |
| positive × negative | negative | 3 × (−4) = −12 |
| negative × negative | positive | −3 × (−4) = 12 |
Division follows exactly the same rules: −12 ÷ 4 = −3, and −12 ÷ (−4) = 3.
The short version: same signs give a positive, different signs give a negative.
Why does negative times negative give a positive?
A pattern makes it believable. Count down by threes:
- 3 × (−4) = −12
- 2 × (−4) = −8
- 1 × (−4) = −4
- 0 × (−4) = 0
Each time the first number drops by 1, the answer goes up by 4. Continue the pattern:
- −1 × (−4) = 4
- −2 × (−4) = 8
An everyday picture: if you lose ₹200 a day (−200), then 3 days ago (−3) you had 600 more than today: −3 × (−200) = +600.
Many negatives
Count the minus signs. An even number of negatives gives a positive answer; an odd number gives a negative one.
- (−1) × (−1) × (−1) = −1 (three negatives: odd)
- (−2) × (−2) × (−2) × (−2) = 16 (four negatives: even)
That's why squaring any number gives a positive result: (−5)² = (−5) × (−5) = 25. This fact is used constantly in statistics and ML, as you'll see below.
Python does the same
print(5 + (-3))
print(5 - (-3))
print(-4 - 6)
print(-3 * -4)
print(-12 / 4)
print((-2) ** 4, (-2) ** 3)
2
8
-10
12
-3.0
16 -8
Absolute value: size without sign
Sometimes only the size of a number matters, not its direction. The absolute value |x| removes the sign:
- |7| = 7
- |−7| = 7
- |0| = 0
print(abs(-7), abs(7), abs(3 - 10))
7 7 7
The distance between two values is the absolute value of their difference: the distance between 3 and 10 is |3 − 10| = 7, whichever way round you subtract. Squares, square roots and absolute value explores this more.
Negative numbers in data science
Errors and residuals
A model predicts a house costs ₹50 lakh, but it sold for ₹45 lakh. The error, actual minus predicted, is 45 − 50 = −5: the model guessed too high. An error of +5 would mean it guessed too low.
If you simply add up the errors, positives and negatives cancel out:
errors = [5, -5, 3, -3]
print(sum(errors))
print(sum(abs(e) for e in errors))
print(sum(e ** 2 for e in errors))
0
16
68
The total error is 0, which looks perfect, but the model was wrong every time. That's why ML measures error using absolute values (the mean absolute error) or squares (the mean squared error). Both turn every error positive. You'll meet both in regression metrics.
Changes over time
Growth can be negative. Sales falling from 120 to 90 is a change of 90 − 120 = −30. Percentage change shows how to express that as −25%.
Coordinates and features
Many features in data are negative by nature: temperatures, longitudes west of Greenwich, profit and loss. And after feature scaling, about half the values in every column become negative, because scaled values measure how far below or above average each value is.
Practice
- Which is warmer: −8 °C or −3 °C?
Show the answer
−3 °C. It's further right on the number line, so it's the bigger number.
- Calculate: (a) −6 + 10 (b) 4 − 9 (c) −2 − (−7) (d) −5 × −6 (e) 18 ÷ (−3)
Show the answer
(a) 4 (b) −5 (c) −2 + 7 = 5 (d) 30 (e) −6
- The temperature was −4 °C at night and 11 °C at noon. By how much did it rise?
Show the answer
11 − (−4) = 11 + 4 = 15 degrees.
- Without calculating the size, is (−1) × (−2) × (−3) × (−4) × (−5) positive or negative?
Show the answer
Negative: there are five negative numbers, an odd count. (Its value is −120.)
- A model's errors are 2, −4, 1 and −1. What's their total, and what's the total absolute error?
Show the answer
Total: 2 − 4 + 1 − 1 = −2. Total absolute error: 2 + 4 + 1 + 1 = 8.
Key takeaways
- On the number line, further left means smaller: −50 < −5.
- Adding a negative is subtracting; subtracting a negative is adding.
- Multiplying or dividing: same signs give positive, different signs give negative.
- Squaring any number gives a positive result, which is why ML squares errors.
- Absolute value gives the size of a number without its sign.
Frequently asked questions
Why does subtracting a negative number make it bigger?
Subtraction measures the gap between numbers. The gap from −3 up to 5 is 8, so 5 − (−3) = 8. In everyday terms, taking away a debt leaves you better off.
Why is a negative times a negative positive?
It keeps the patterns of multiplication consistent. As you multiply −4 by 2, 1, 0, −1, −2, the answers go −8, −4, 0, 4, 8, increasing steadily, so multiplying two negatives must give a positive.
Is zero positive or negative?
Neither. Zero is the dividing point between positive and negative numbers.
What to learn next
- Learn to work with parts of a whole in fractions explained step by step.
- Revisit the order of operations.