[Solved] Why does Math.round(1.53*20)/20 = 1.55? How does this actually work?


Math.round() will return the nearest integer value as described here

For your input Math.round(1.53*20)/20 it will first calculate 1.53*20 answer is 30.6 Then your expression becomes

Math.round(30.6)/20

After that result of Math.round(30.6) is 31 (nearest integer)
Then your statement becomes 31/20 which is 1.55

solved Why does Math.round(1.53*20)/20 = 1.55? How does this actually work?