0

I have the following below code, which works as :

num = 191360.789242721
round(num , -3)/1000
>>> 191.0

But how I can round UP and get 192.0 ?

Jrh
  • 37
  • 1
  • 9

2 Answers2

2
num = 191360.789242721
math.ceil(num/1000)
>>> 192
AimiHat
  • 383
  • 4
  • 14
2

You can use math.ceil() as a ready-made solution or do it manually with a reverse floor division:

num = 191360.789242721
num_ceil = -(-num // 1000)  # 192.0
zwer
  • 24,943
  • 3
  • 48
  • 66