The module math.ceil()
enables to round up decimals in Python. This module only covers a type from float
to int
. This post shows tips that round up decimals by specifying decimal digit length.
def my_ceil(x: Union[float, int], exponential: int = 2) -> float:
import math
_expo = 10 ** exponential
return math.ceil(x * _expo) / _expo
Top comments (0)