Homeomorphism between $\mathbb{Q}$ and $\mathbb{Q}(>0)$, and $\mathbb{Q}(\ge 0)$
The following function is a homeomorphism between $\mathbb{Q}$ and $\mathbb{Q}_{>0}$ : $$f(x) = \begin{cases} \frac{-1}{x}, & \text{if } x<-1 \\ x+2, & \text{if } x \geq -1 \end{cases}.$$
For a homeomorphism between $\mathbb{Q}_{\geq 0}$ and $\mathbb{Q}$, I will rather construct a homeomorphism between $[0,\sqrt{2}[ \cap \mathbb{Q}$ and $]-\sqrt{2},\sqrt{2}[ \cap \mathbb{Q}$. Let $f : [0,1[ \cap \mathbb{Q} \rightarrow \mathbb{Q}$ defined by :
- $f(0) =0$.
- For all $n \in \mathbb{N_{\geq 1}}$, $f$ is a homeomorphism from $]\frac{\sqrt{2}}{2n+1},\frac{\sqrt{2}}{2n}[ \cap \mathbb{Q}$ to $]\frac{\sqrt{2}}{n+1},\frac{\sqrt{2}}{n}[ \cap \mathbb{Q}$.
- For all $n \in \mathbb{N_{\geq 1}}$, $f$ is a homeomorphism from $]\frac{\sqrt{2}}{2n},\frac{\sqrt{2}}{2n-1}[ \cap \mathbb{Q}$ to $]-\frac{\sqrt{2}}{n},-\frac{\sqrt{2}}{n+1}[ \cap \mathbb{Q}$.
Then :
The function $f$ is one to one from $[0,\sqrt{2}[ \cap \mathbb{Q}$ to $]-\sqrt{2},\sqrt{2}[ \cap \mathbb{Q}$.
It is continuous on $]0,\sqrt{2}[ \cap \mathbb{Q}$ because it is continuous on the open covering $(]\frac{\sqrt{2}}{k+1},\frac{\sqrt{2}}{k}[)_{k \geq 1}$.
It is continuous at $0$ because $f([0,\frac{\sqrt{2}}{2k}[) \subset (]-\frac{\sqrt{2}}{k},\frac{\sqrt{2}}{k}[)$.
For the same reasons $f^{-1}$ is continuous on $(]-\sqrt{2}[ \cup ]\sqrt{2}[) \cap \mathbb{Q}$ and at $0$.