python中的模是如何工作的?

2024-09-29 01:28:18 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么 -4%5 => 1 //I understand -5%5 => 0 //I understand -6%5 => 4 // My mind has been deleted

我在c/cpp里查了一下,结果只有-1。你知道吗


Tags: mycpphasbeenminddeletedunderstand
1条回答
网友
1楼 · 发布于 2024-09-29 01:28:18

-6:小于或等于-6并可被5整除的最大数是-10。你知道吗

# just like the other examples
-4 - (-5) == 1  
-5 - (-5) == 0  
-6 - (-10) == 4  # fits perfectly in there
-7 - (-10) == 3  
-8 - (-10) == 2  

相关问题 更多 >