Lor*_*iel 0 javascript math modulo
如果模数(%)与正数的"余数(r)"相同,那么为什么"0.86%1"结果为"0.86"而不是"0",因为"0.86/1 = 0.86",余数为0.
我已经看到了其他问题,但没有一个问题解决了1个条件下的模型.我能够理解这一点的唯一方法是认为0.86小于1,因此不能除以1,因此返回0.86作为余数.
你说
"0.86/1 = 0.86",余数= 0.
好吧,只有在5/2 = 2.5且余数为0的意义上,很清楚这有什么不对,对吧?
当我们谈论剩余时,商必须是整数.它不能是2.5或0.86.如果你尽可能多地从除数中除去除数的倍数,剩下的就是余数.对于5/2,我们有
5-2 = 3
3-2 = 1
2>1, so we can't subtract any more, and the remainder is 1
Run Code Online (Sandbox Code Playgroud)
对于0.86/1,我们有
1>0.86, so we can't subtract any copies of 1 from 0.86, and the remainder is 0.86
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
109 次 |
| 最近记录: |