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

后端 未结 5 833

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:54

    In mathematics the result of the modulo operation is the remainder of the Euclidean division. However, other conventions are possible. Computers and calculators have various ways of storing and representing numbers; thus their definition of the modulo operation depends on the programming language and/or the underlying hardware.

     7 modulo  3 -->  1  
     7 modulo -3 --> -2 
    -7 modulo  3 -->  2  
    -7 modulo -3 --> -1 
    

提交回复
热议问题