q********g 发帖数: 10694 | 1 a = -28.362739299
b = round(a, 2)
结果还是一大串小数。为啥嗫,怎么也想不通。试了试,只有round(a)管用。
大牛小牛都来帮忙啊。给ld编一个处理数据的,没办法现学的。 | X****r 发帖数: 3557 | 2 Most non-integer decimals cannot be accurately represented
as floating point number, which is in binary. Thus you get
b = -28.359999999999999 or something like that. It shouldn't
bother you in most cases -- just format it before printing
it out, e.g. '%.2f' % b will give you '-28.36'.
【在 q********g 的大作中提到】 : a = -28.362739299 : b = round(a, 2) : 结果还是一大串小数。为啥嗫,怎么也想不通。试了试,只有round(a)管用。 : 大牛小牛都来帮忙啊。给ld编一个处理数据的,没办法现学的。
| q********g 发帖数: 10694 | |
|