这是怎么回事
print 'steps divided',125**(1.0/3), 5.0%1
>> steps divided 5.0 0.0
print 'steps combined',(125**(1.0/3))%1
>> steps combined 1.0
奇怪的是,这些步骤适用于其他数字。。。。例8:
print 'steps divided',8**(1.0/3), 2.0%1
>> steps divided 2.0 0.0
print 'steps combined',(8**(1.0/3))%1
>> steps combined 0.0
我认为这解决了你的问题
125**(1.0/3)
实际上是4.999...
,而不是5.0
因此,您正在执行
4.999999999999999%1
,这将为您提供.0.9999999999989999
的输出,它将四舍五入为1相关问题 更多 >
编程相关推荐