分数(1.2)vs分数(' 1.2;)
当我使用分数
从分数
模块类
from fractions import Fraction
Fraction(1.2)
,
Fraction(5404319552844595, 4503599627370496)
允许
Fraction('1.2')
给出,
Fraction(6, 5)
请注意,
5404319552844595/4503599627370496
给出1.2
作为输出。
那么,都不应该将分数(6,5)
作为输出。
When I use the Fraction
class from fractions
module
from fractions import Fraction
Fraction(1.2)
gives,
Fraction(5404319552844595, 4503599627370496)
whereas,
Fraction('1.2')
gives,
Fraction(6, 5)
notice that,
5404319552844595/4503599627370496
gives 1.2
as output.
Then shouldn't both give Fraction(6, 5)
as output.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论