Reputation: 479
In Python floor()
and ceil()
round to the next higher or lower integer.
How to round up any value between 1.01 - 1.5 to 1.5 and 1.51 - 2.0 to 2.0 etc.?
Upvotes: 11
Views: 8477
Reputation: 601679
Multiply by two, ceil()
, divide by two:
0.5 * ceil(2.0 * x)
Upvotes: 27