What's the difference between “mod” and “remainder”?

后端 未结 5 892

My friend said that there are differences between \"mod\" and \"remainder\".

If so, what are those differences in C and C++? Does \'%\' mean either \"mod\" or \"rem\

5条回答
  •  轮回少年
    2020-11-22 04:49

    There is a difference between modulus and remainder. For example:

    -21 mod 4 is 3 because -21 + 4 x 6 is 3.

    But -21 divided by 4 gives -5 with a remainder of -1.

    For positive values, there is no difference.

提交回复
热议问题