I tired to round 3.666666 for two digit and get 3.66. But Round() function give me 3.67. Is there a way to solve this problem with the round function without converting it to string type?
a=round(3.666666,2)
I tired to round 3.666666 for two digit and get 3.66. But Round() function give me 3.67. Is there a way to solve this problem with the round function without converting it to string type?
a=round(3.666666,2)
Use math.floor()
instead of round. floor
rounds down, ceil
rounds up, round
rounds mathematically, either up or down.
To round to two characters after the decimal point, you can multiply it with 10^2 (100) before rounding and then divide it afterwards by the same number.
Here is an example:
import math
math.floor(value * 100) / 100