Finding Injectivity in function I have a doubt with the following problem. I have to find if the function is injective, surjective and if bijective find the inverse function
$$f : \mathbb{Z} \longrightarrow \mathbb{N},\qquad
f(a) = 
     \begin{cases}
       2a  & \text{if } a >0, \\
       1 - 2a & \text{if } a \le 0. \\
     \end{cases}$$
The solution to the problem:
Injectivity: $f(a)=f(b) \Rightarrow a=b$. Taking a $x_{1}$,$x_{2} \in \mathbb{Z}$, I separate into the following cases:
1) $x_ {1} > 0$, $x_{2} > 0:\; 2x_{1} = 2x_{2} \Rightarrow x_{1} = x_{2}$
2) $x_ {1} \le 0$, $x_{2} \le 0:\; 1-2x_{1} = 1-2x_{2} \Rightarrow x_{1} = x_{2}$
3) $x_{1} > 0, x_{2} \le 0:\;2x_{1} = 1-2x_{2} \Rightarrow 2x_{1} + 2x_{2} = 1 \Rightarrow (x_{1} + x_{2}) = 1/2$
The case $x_{2} > 0$, $x_{1} \le 0$, gives the same answer as the third case. My question is that if this conclusion makes the function not injective, or it simply is telling me that this is a case that cannot happen since $x_{1}$,$x_{2} \in \mathbb{Z}$.
Putting aside this, the function also is surjective and I could find the inverse function, that is 
$$f^{-1} : \mathbb{N} \longrightarrow \mathbb{Z},\qquad f^{-1}(a) = 
     \begin{cases}
       \text{a/2} &\text{if $a$ is even,} \\
       \text{(1 - a)/2} &\text{if $a$ is odd.} \\
     \end{cases}
$$
Is this correct?
PD: First time writing LATEX, feedback is very welcomed!

The function is injective if you draw the graph. It looks like a ''V''.
But it is not surjective, since $0$ doesn't lie in the image: If $a>0$, then $f(a)=2a>0$ and if $a$ is non-positive, the function has the form: $f(0) = 1$, $f(-1)=3$, $f(-2)=5$ and so on.
