Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is 0 mod 0 an error?

If I type:

int main() { return 0 % 0; }

I get back an error:

error C2124: divide or mod by zero

What is the reason behind this? Isn't the answer zero?

like image 788
user541686 Avatar asked Oct 15 '13 00:10

user541686


People also ask

Why is mod 0 undefined?

All numbers = to, say m < n mod(n), have the same remainder m when divided by n. Since mod(0) would thus require division by 0, which is undefined, mod(0) would also be undefined.

Can we put 0 in mod?

If you mean "the remainder after dividing", you can't divide by zero, so it's not defined.

What error do you get if you try to mod an integer with 0?

3 things you should know about MOD in Excel If the divisor is 0, MOD returns the #DIV/0! error because you cannot divide by zero. If the number or divisor is a text value, an Excel Mod formula returns the #VALUE! error.

What is the value of modulus 0?

The modulus of 0 is 0. So, the modulus of a positive number is simply the number. The modulus of a negative number is found by ignoring the minus sign. The modulus of a number is denoted by writing vertical lines around the number.


1 Answers

In mathematics, x mod 0 is undefined, hence the error.

like image 167
David G Avatar answered Sep 19 '22 22:09

David G