Rounding up means moving a number to the next greater integer or the next greater multiple. In Python, the standard way to round a number up to an integer is math.ceil(). Do not use round() when you specifically need always-upward rounding: round() rounds to the nearest value, and ties go to the even choice. For how integers and floats behave under the hood, see Python numbers.
This guide covers math.ceil(), ceiling division, rounding up to multiples of 5 or 10, decimal-place ceiling with Decimal, and numpy.ceil() for arrays. For a deeper look at the ceiling function itself, see Python ceil function.
Tested on: Python 3.13.3; kernel 6.14.0-37-generic.
Quick answer: round up in Python
Use math.ceil(number) to round up to the nearest integer. Do not use round() when you need always-upward rounding.
import math
print(math.ceil(3.1))
print(math.ceil(3.9))Both lines print 4. math.ceil(4.0) also prints 4 because the value is already an integer.
Python round up quick reference
| Task | Use |
|---|---|
| Round up to integer | math.ceil(x) |
| Round up 3.1 to 4 | math.ceil(3.1) |
| Round up division | math.ceil(a / b) |
| Integer ceiling division | -(-a // b) |
| Round up to nearest 10 | math.ceil(x / 10) * 10 |
| Round up to nearest 5 | math.ceil(x / 5) * 5 |
| Round up to 2 decimals | Decimal with ROUND_CEILING or scale with math.ceil() |
| Round up NumPy array | numpy.ceil(array) |
| Round to nearest value | round(x) |
| Round down | math.floor(x) |
What does round up mean in Python?
Rounding up means moving to the nearest greater or equal value.
For positive numbers:
3.1rounds up to4.3.9rounds up to4.4.0stays4.
For negative numbers, ceiling still moves toward positive infinity:
math.ceil(-3.1)returns-3because-3is greater than-3.1.
This behavior is called the ceiling. Python defines math.ceil(x) as the smallest integer greater than or equal to x.
Round up using math.ceil()
Import math, then call math.ceil(number). It returns an int and works with positive and negative numbers. This should be your first choice when you need upward rounding to an integer.
import math
print(math.ceil(3.1))
print(math.ceil(3.8))
print(math.ceil(4))
print(type(math.ceil(3.1)))The first three lines print 4, 4, and 4. The type line prints <class 'int'>.
import math
print(math.ceil(-3.1))
print(math.ceil(-3.7))Both lines print -3. The result moves toward positive infinity, not toward zero.
Why round() is not round up
round() rounds to the nearest value. Sometimes that means rounding down. When two values are equally close, Python rounds to the even choice.
print(round(3.2))
print(round(3.8))
print(round(2.5))
print(round(1.5))
print(round(0.5))This prints 3, 4, 2, 2, and 0. round(2.5) returns 2, not 3. round() is not suitable when you need always-upward rounding.
String formatting and round(num, 2) also round to nearest, not upward. Do not treat "{:.2f}".format(num) or round(num, 2) as ceiling operations.
round() vs math.ceil()
| Function | Meaning | Example |
|---|---|---|
round(x) |
Round to nearest | round(3.2) → 3 |
math.ceil(x) |
Round upward | math.ceil(3.2) → 4 |
math.floor(x) |
Round downward | math.floor(3.8) → 3 |
int(x) |
Truncate toward zero | int(3.8) → 3 |
Use math.ceil() for ceiling. Use round() only when nearest-value rounding is what you want. For rounding down, see Python floor function.
Round up division in Python
Use math.ceil(a / b) when you need enough pages, batches, chunks, or groups to cover a total.
import math
items = 43
per_page = 10
pages = math.ceil(items / per_page)
print(pages)This prints 5. Four full pages hold 40 items; the remaining 3 items need one more page.
For positive integers, integer ceiling division avoids floating-point division:
items = 43
per_page = 10
pages = -(-items // per_page)
print(pages)This also prints 5. The expression -(-a // b) applies floor division, then negates twice to get the ceiling of the quotient. The // operator is floor division; ** handles powers when you scale before ceiling.
Round up to nearest 10
Formula: math.ceil(number / 10) * 10.
import math
num = 457583
rounded_up = math.ceil(num / 10) * 10
print(rounded_up)This prints 457590.
round(number, -1) rounds to the nearest 10, not always upward:
num = 457583
print(round(num, -1))
print(math.ceil(num / 10) * 10)The first line prints 457580. The second prints 457590. Use math.ceil() when you need the next higher multiple of 10.
Round up to nearest 5
Formula: math.ceil(number / 5) * 5.
import math
print(math.ceil(11 / 5) * 5)
print(math.ceil(10 / 5) * 5)The first line prints 15 because 11 is not already a multiple of 5. The second prints 10 because 10 is already a multiple of 5.
5 * round(num / 5) rounds to the nearest multiple of 5, which can round down. Use math.ceil(num / 5) * 5 when you need the next higher multiple.
Round up to any multiple
General formula: math.ceil(number / multiple) * multiple.
import math
def round_up_to_multiple(number, multiple):
return math.ceil(number / multiple) * multiple
print(round_up_to_multiple(4343, 5))
print(round_up_to_multiple(457583, 10))
print(round_up_to_multiple(1234, 100))This prints 4345, 457590, and 1300. The same pattern works for pricing tiers, page sizes, chunking, and grouping.
Round up to 2 decimal places
math.ceil() returns an integer. To round up to a fixed number of decimal places, scale up, apply ceiling, then scale back.
import math
x = 3.786847638
two_decimals = math.ceil(x * 100) / 100
print(two_decimals)This prints 3.79.
Binary floating-point can produce surprising decimal results. For example, 0.1 + 0.2 is not exactly 0.3 in IEEE-754 arithmetic. When exact decimal rounding matters, use Decimal.
Round up with Decimal
Use Decimal when you need exact decimal-place control. Pass an explicit rounding mode to quantize().
from decimal import Decimal, ROUND_CEILING, ROUND_UP
value = Decimal('3.786847638')
print(value.quantize(Decimal('0.01'), rounding=ROUND_CEILING))This prints 3.79.
For negative numbers, ROUND_CEILING and ROUND_UP can differ:
from decimal import Decimal, ROUND_CEILING, ROUND_UP
value = Decimal('-3.711')
print(value.quantize(Decimal('0.01'), rounding=ROUND_CEILING))
print(value.quantize(Decimal('0.01'), rounding=ROUND_UP))The first line prints -3.71 (toward positive infinity). The second prints -3.72 (away from zero). Choose the mode that matches your business rule.
Round up NumPy arrays using numpy.ceil()
Use numpy.ceil() for arrays. It applies ceiling element-wise and returns a floating array or scalar. Do not use numpy.round() when you need upward rounding.
import numpy as np
arr = np.array([1.1, 2.6, 4.6, 4.8, 10.0])
print(np.ceil(arr))
print(np.round(arr))
print(type(np.ceil(3.1)))[ 2. 3. 5. 5. 10.]
[ 1. 3. 5. 5. 10.]
<class 'numpy.float64'>np.ceil() returns [2., 3., 5., 5., 10.]. np.round() rounds to nearest, so 1.1 becomes 1.0 instead of 2.0. Install NumPy locally with pip install numpy if needed.
The NumPy documentation defines numpy.ceil() as returning the ceiling of the input element-wise, where the ceiling is the smallest integer i such that i >= x.
Round up negative numbers
math.ceil(-3.7) returns -3, not -4. Ceiling moves toward positive infinity, which surprises beginners who expect "up" to mean away from zero.
import math
print(math.ceil(-3.7))
print(math.ceil(-3.1))Both lines print -3.
If you need away-from-zero rounding for negatives, that is a different rule. Use Decimal with ROUND_UP, or apply math.ceil(abs(x)) with a sign only when your domain is non-negative.
Common mistakes when rounding up in Python
- Using
round()whenmath.ceil()is needed. - Expecting
round(2.5)to return3; Python returns2because ties round to even. - Assuming
"{:.2f}"orround(num, 2)always rounds up. - Using
numpy.round()instead ofnumpy.ceil()for upward array rounding. - Forgetting
import math. - Treating ceiling as "away from zero" for negative numbers.
- Using
round(number, -1)or5 * round(num / 5)when you need the next higher multiple. - Using integer floor division
a // bwithout the-(-a // b)ceiling trick when you need a full extra unit for remainder. - Searching for a built-in
roundup()function; Python does not provide one. - Misspelling NumPy as "nampy" in docs or imports.
Summary
Use math.ceil() to round up to an integer. Use math.ceil(x / multiple) * multiple to round up to a multiple of 5, 10, 100, or any other step. Use -(-a // b) for integer ceiling division on positive integers. Use math.ceil(x * 100) / 100 or Decimal with ROUND_CEILING when exact decimal-place rounding matters. Use numpy.ceil() for arrays. Do not use round() when you need always-upward rounding.

