I was searching for a function which, given a float, will restore an int of the float amazed or adjusted to the closest int. Is there something like this built-in or accessible in a module?
The accompanying code gets the job done however I try not to waste time.
import math
def realround(number):
_, d = divmod(number, 1)
if d > 0.5:
return int(math.ceil(number))
else:
return int(math.floor(number))
print(realround(12.3))
print(realround(14.5))
print(realround(15.8))