这是证明:
-8 == -2 * 3 - 2
Run Code Online (Sandbox Code Playgroud)
这意味着-8%3应该等于-2.但是python回归1并且它让我疯狂
整数数学很有趣:
>>> -8//3 # (-8/3 in python2 does the same thing)
-3
>>> 8//3 # (8/3 in python2 does the same thing)
2
>>>
Run Code Online (Sandbox Code Playgroud)
舍入做下来,不会接近零.