How Does Modulus Divison Work

后端 未结 19 1587
栀梦
栀梦 2020-11-22 06:55

I don\'t really understand how modulus division works. I was calculating 27 % 16 and wound up with 11 and I don\'t understand why.

I can\'t

19条回答
  •  -上瘾入骨i
    2020-11-22 07:13

    The result of a modulo division is the remainder of an integer division of the given numbers.

    That means:

    27 / 16 = 1, remainder 11
    => 27 mod 16 = 11
    

    Other examples:

    30 / 3 = 10, remainder 0
    => 30 mod 3 = 0
    
    35 / 3 = 11, remainder 2
    => 35 mod 3 = 2
    

提交回复
热议问题