Hacker News new | ask | show | jobs
by x86x87 836 days ago
> This also makes sense when you consider modulus operator. 37 % 7 gives 2 meaning 5 groups of 7 with 2 remaining in the last group.

Where is this coming from? The modulus is just integer division with a remainder. If you use your theory of interpreting this you can do it both ways.

Division is taking something and spliting it in X parts. By definition: the act of separating something into parts or groups

So when you are divinding by X you are separating the initial quantity into X equal parts.

35/7 means divide 35 in 7 equal parts.

1 comments

> 35/7 means divide 35 in 7 equal parts

This means each part has 5 things in it and there are 7 such parts which is fundamentally irreconcilable with the modulus operator. I think it is because of the limitation of the modulus operator which only works for integer values. So what you’re saying makes sense with real numbers BUT the context changes when you’re working with integers. So, with integer values it is 5 groups of 7 but 7 groups of 5 with real numbers

It does not. Modulus is only defined for integers. The point was that the 57 or 75 does not matter when you are looking at the remainder.

Modulus in this case means divide into 7 parts and when you cannot divide anymore keep the reminder.

If x = a*b+c

x ℅ a = c and x % b = c

41 = 7*5 + 6

41 % 7 = 6

41 % 5 = 1

Good point. But it's still integer division with a remainder