I don't know if this is the right stackexchange for this question, please tell me/move it if it isn't.
I calculate a value $x$ that can be any integer number. I now want to use this variable to get a factor thats $0$ if $x$ is zero, and 1 if it isn't.
I can easily program this with an if-statement, however due to optimization reasons, I want to get around the if. So I was wondering if there is a mathematical expression that would give me $fac = 1$ if $x\ne0$ and $fac=0$ if $x = 0$.
You can set a new variable equal to the floor of $x/(x-1)$. ( as long as $x$ can't be equal to $1$). Alternatively the ceiling of $x/(x+1)$ (as long as $x$ isn't negative).