Decimal Place Value
Decimals extend place value to the right of the decimal point: tenths, hundredths, thousandths and so on. This lesson names the decimal places, shows how decimals relate to fractions with denominators 10, 100 and 1000, compares decimals, and introduces Python's Decimal type for exact base-10 numbers.
Places to the right of the point
In place value each place is worth 10 times the place to its right. Keep going past the ones place and you get places worth , , of a unit:
4 7 . 2 0 5
│ │ │ │ └─ thousandths 5 × 1/1000
│ │ │ └─────── hundredths 0 × 1/100
│ │ └───────────── tenths 2 × 1/10
│ └─────────────────── ones 7 × 1
└───────────────────────── tens 4 × 10So . You read it "forty-seven and two hundred five thousandths", or simply "forty-seven point two zero five".
| Place | Value | Example digit in 0.3618 |
|---|---|---|
| tenths | 3 | |
| hundredths | 6 | |
| thousandths | 1 | |
| ten-thousandths | 8 |
Decimals are fractions with power-of-ten denominators
The number of digits after the point tells you the denominator:
Python's Fraction can read a decimal string exactly and simplify it:
from fractions import Fraction
for text in ["0.7", "0.45", "0.125", "3.06", "47.205"]:
f = Fraction(text)
print(f"{text:>7} = {f}") 0.7 = 7/10
0.45 = 9/20
0.125 = 1/8
3.06 = 153/50
47.205 = 9441/200
Trailing and leading zeros
- Zeros at the end after the point do not change the value: . They can still carry meaning: a price of 2.50 shows cents, and a measurement of 2.500 m claims millimetre precision.
- Zeros between the point and a digit do matter: 0.05 (five hundredths) is ten times smaller than 0.5 (five tenths).
- Write a leading zero before the point (0.5, not .5). It is easier to read and harder to misread.
Comparing decimals
Line up the decimal points and compare place by place from the left. Padding with zeros helps:
0.6 → 0.600
0.58 → 0.580 0.600 > 0.580 > 0.098
0.098 → 0.098A common mistake is to think "because ". Compare tenths first: 6 tenths beats 5 tenths.
Decimal in Python
A float stores numbers in binary, and most decimal fractions (like 0.1) have no exact binary form. Python's decimal module stores base-10 digits exactly, the way you write them:
from decimal import Decimal
price = Decimal("2.50")
print(price, price == Decimal("2.5")) # same value, keeps its digits
print(Decimal("0.6") > Decimal("0.58"))
print(Decimal("47.205").as_tuple())
print(Decimal(0.1)) # the float 0.1, shown exactly: not quite 0.1
print(Decimal("0.1")) # built from a string: exactly 0.12.50 True
True
DecimalTuple(sign=0, digits=(4, 7, 2, 0, 5), exponent=-3)
0.1000000000000000055511151231257827021181583404541015625
0.1
as_tuple() shows the idea behind decimals directly: the digits 47205 and an exponent of −3, meaning "move the point 3 places left".
Tip: Always build a
Decimalfrom a string (Decimal("0.1")) or an integer, never from a float literal.Decimal(0.1)faithfully copies the float's tiny binary error.
In software
- Money. Prices, invoices and bank balances are decimal quantities with a fixed number of places. Finance code uses
Decimal(Python),BigDecimal(Java),decimal(C#) or integer cents, never plain floats. The next lessons show why. - Databases have a
DECIMAL(10, 2)/NUMERICcolumn type for exactly this purpose. - Version numbers are not decimals. Version 1.10 is newer than 1.9, but as decimals . Compare versions part by part as integers.
Exercises
Exercise 1: Digit values
In 6.4729, what is the value of the 7 and of the 9?
Answer
The 7 is 7 hundredths (0.07); the 9 is 9 ten-thousandths (0.0009).
Solution
Counting places after the point: 4 is tenths, 7 is hundredths, 2 is thousandths, 9 is ten-thousandths. So and .
Exercise 2: Decimal to fraction
Write 0.36 and 2.875 as fractions in lowest terms.
Answer
and ().
Solution
Exercise 3: Order them
Order from smallest to largest: 0.405, 0.45, 0.4, 0.0455.
Answer
Solution
Pad to four places: 0.4050, 0.4500, 0.4000, 0.0455. Now compare as whole numbers of ten-thousandths: .
from decimal import Decimal
values = ["0.405", "0.45", "0.4", "0.0455"]
print(sorted(values, key=Decimal))['0.0455', '0.4', '0.405', '0.45']
Exercise 4: Versions are not decimals
Write a function that sorts version strings like "1.9", "1.10", "1.2" correctly, and show how sorting them as Decimal gets it wrong.
Answer
Correct order: 1.2, 1.9, 1.10. As decimals: 1.10, 1.2, 1.9.
Solution
Split on the dot and compare the parts as integers (tuples compare element by element).
from decimal import Decimal
versions = ["1.9", "1.10", "1.2"]
print("as versions:", sorted(versions, key=lambda v: tuple(int(p) for p in v.split("."))))
print("as decimals:", sorted(versions, key=Decimal))as versions: ['1.2', '1.9', '1.10']
as decimals: ['1.10', '1.2', '1.9']
Test yourself
In 3.582, which digit is in the hundredths place?
- 3
- 5
- 8
- 2
Which is the largest?
- 0.7
- 0.69
- 0.698
- 0.0799
Why write Decimal("0.1") instead of Decimal(0.1)?
- Strings are faster
- The float 0.1 is already slightly wrong, and Decimal copies that error
- Decimal cannot take numbers
- There is no difference