Prove that the following function is invertible: $g:\mathbb{Z}\rightarrow\mathbb{N}$
$ g(x) = \left\{ \begin{array}{lr} -2x & : x\le0\\ 2x-1 & : x>0 \end{array} \right. $
I'm having an issue proving that it is one-to-one in all cases. The cases where $x_{1},x_{2}\le0$ and $x_{1},x_{2}>0$ both pass proof by contrapostitive where $g(x_{1})=g(x_{2})$. I'm having a problem proving it is also one-to one if $x_{1}\le0$ but $x_{2}>0$ which would result in:
$ -2x_{1}=2x_{2}-1 $ $ x_{1}=-x_{2}+\frac{1}{2} $
I know I'm going something wrong in my thinking and I have a sneaking suspicion it has something to do with the fact that I'm mapping to $\mathbb{N}$, but I'm completely unsure of where to go from here.