Ç模运算符 [英] c modulus operator
本文介绍了Ç模运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当你用消极的运营%会发生什么。
例如-3%2或3%-2
what happens when you use negative operators with %. example -3%2 or 3%-2
推荐答案
在C89,C90和C ++ 03标准只要求(A / B)* B + A%B = = A
为 /
和%
运营商。
In C89, C90, and C++03 the standards requires only that (a/b)*b+a%b == a
for the /
and %
operators.
如果两个操作数都是非负则剩余部分非负;
如果不是,其余的符号是实现定义
If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined
编辑:在C99负数将返回如果第一个参数为负
In C99 a negative number will be returned if the first argument is negative
这篇关于Ç模运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文