Python float to ratio

前端 未结 2 1727
说谎
说谎 2020-12-10 07:08

I try get ration of variable and get unexpected result. Can somebody explain this?

>>> value = 3.2
>>> ratios = value.as_integer_ratio()
&g         


        
2条回答
  •  自闭症患者
    2020-12-10 07:16

    It's not 16/5 because 3.2 isn't 3.2 exactly... it's a floating point rough approximation of it... eg: 3.20000000000000017764

提交回复
热议问题