# What is the value of $1\%0$?

Let $x$ be an integer which can take a value of $0$ or $1$. The statement

if $(x = = 0) x = 1;$ else $x = 0;$

is equivalent to which one of the following ?

1. $x = 1 + x;$
2. $x = 1 - x;$
3. $x = x - 1;$
4. $x = 1\% x;$

My attempt :

It should be only option $(2)$ is true. but,

Can you explain little bit please, what is the value of $1\%0$ ?

AFAIK: It should be undefined, since it applied division $1/0$ which is undefined.

• This sounds more like a programming question than a mathematics one. I suspect as code it would throw a run time error if you tried to do mod zero. – Ian Miller Nov 18 '15 at 13:36
• Mathematicians tend not to use % as an operator, and we tend not to assign variables new values. This is a coding problem? The best definition would be that $a%0==a$ for all $a$, but who knows what it would be in the language at hand - depends precisely on the definition. – Thomas Andrews Nov 18 '15 at 13:36
• You can find your answer over here - math.stackexchange.com/questions/516251/… – mihir Nov 18 '15 at 13:37
• If you are talking about the C programming language, then the behaviour of 1%0 is undefined, see for example stackoverflow.com/questions/7370154/cant-mod-zero. That might be different for other programming languages. – Martin R Nov 18 '15 at 13:37
• Mathematicians typically use = for equations, and indicate the assignment of a new value as := or a leftward pointing $\mapsto$ (not sure what the symbol for this is). In your case, since $x$ is boolean, the assignment can be written as $x := NOT x$ or $x := 1-x$, since the assignment inverts TRUE and FALSE. – Marconius Nov 19 '15 at 0:15

"$1\%0$" would be equivalent to $1-\Big\lfloor\frac10\Big\rfloor\times0$.
Modulo by $0$ is as meaningless as Division by $0$.
• Is $\%$ operator dependents on division operator? – ً ً Nov 18 '15 at 13:49
• Is $x = x\% 1$ is equivalent to $x = 1 - x$ ? – ً ً Nov 18 '15 at 13:58
• @MithleshUpadhyay: $\forall{n\in\mathbb{Z}}:n\%1=0$. – barak manos Nov 18 '15 at 14:01