+ 1

How this function rounds off the value?... Please explain.

a=round(1234.1234,-1) print (a)

14th May 2020, 8:16 PM
Bhanu Tripathi
Bhanu Tripathi - avatar
4 Antworten
+ 5
the first parameter is the float number which will be rounded, and the second is how many digits after the . (dot) will be rounded. if the second parameter is negative then it will round behind the dot instead of after, therefore: round(1234.1234, -1) will result in 1230.0 because 34 rounded is 30 round(1236.1234, -1) will result in 1240.0 because 36 rounded is 40 round(1234.1234, -2) will result in 1200.0 because 23 rounded is 20
14th May 2020, 8:24 PM
Sebastian Pacurar
Sebastian Pacurar - avatar
+ 2
i reedited the answer just for that, look above
14th May 2020, 8:28 PM
Sebastian Pacurar
Sebastian Pacurar - avatar
0
And what about round (1234.1234,-2)
14th May 2020, 8:26 PM
Bhanu Tripathi
Bhanu Tripathi - avatar
0
Thanks a lot...@@
14th May 2020, 8:30 PM
Bhanu Tripathi
Bhanu Tripathi - avatar