I am trying to round up 5.9999998 to 5.999.
But I have a problem, If I do round(number) it'll round it up to 6. How can I round a number like this to max 3 decimals?
CodePudding user response:
You can use this:
number = 5.999999998
new_number = int(number * 1e3) / 1e3
CodePudding user response:
Here is a short code.
x = 4/3
# round up to 3 decimal places
x = round(x, 3)
print(x)