Round number to nearest integer

前端 未结 11 2124
傲寒
傲寒 2020-11-27 12:32

I\'ve been trying to round long float numbers like:

32.268907563;
32.268907563;
31.2396694215;
33.6206896552;
...

With no success so far. I

11条回答
  •  清歌不尽
    2020-11-27 13:21

    If you need (for example) a two digit approximation for A, then int(A*100+0.5)/100.0 will do what you are looking for.

    If you need three digit approximation multiply and divide by 1000 and so on.

提交回复
热议问题