求模运算符的作用远不止如此。
SQL不支持对浮点数字使用取模运算符。
SQL does not support the modulus operator on floating-point Numbers.
在这种情况下你最好的选择是使用绝对值做模运算符时如果你想基本整数的除法。
Your best bet in situations like this is to operate on absolute values when doing modulo operators if you want basic integer division.
原先是简单的使用取模运算符(%)的实现,它非常低效,它自己检查从2到目标数的每个数字,确定是否是因子。
The original naive implementation used the modulus (%) operator, which is wildly inefficient, to check every number from 2 up to the target number itself to determine if it is a factor.
另外一个方法就是使用求模运算符了,百分号%就是了,求模运算就是求余数,会把两个数相除然后返回余数。
An alternative is to use the modulus operator, %, which divides two Numbers and returns the remainder.
练习4 - 3在有了基本框架后,对计算器程序进行扩充就比较简单了。在该程序中加入取模(%)运算符,并注意考虑负数的情况。
Exercise 4-3. Given the basic framework, it's straightforward to extend the calculator. Add the modulus (%) operator and provisions for negative Numbers.
练习4 - 3在有了基本框架后,对计算器程序进行扩充就比较简单了。在该程序中加入取模(%)运算符,并注意考虑负数的情况。
Exercise 4-3. Given the basic framework, it's straightforward to extend the calculator. Add the modulus (%) operator and provisions for negative Numbers.
应用推荐