【发布时间】:2021-10-07 01:06:54
【问题描述】:
在 Python 中,在划分较大的值时,我得到的输出不准确,例如:-
(1227073724601519345/101) = 12149244798034845。但是在Python中它变成了
(1227073724601519345/101) = 1.2149244798034844e+16 转换为 int 为 12149244798034844。
如你所见
( correct_output - approx_output ) = 1
有什么办法可以避免这种情况吗?将更大的数字相乘时不会出现这种不准确性,例如:-
(123468274768408415066917747313280346049^2) - (56 * (16499142225694642619627981620326144780^2)) = 1
这是准确的。
【问题讨论】:
标签: python division approximation