TITLE: Explicit bijection between $\mathbb Q$ and $\mathbb Z \times \mathbb Z$?
QUESTION [6 upvotes]: Any idea of an explicit bijection between $\mathbb Q$ and $\mathbb Z \times \mathbb Z$? Even if I think of rational elements as $\frac {m}{n}$, sending them to $(m,n)$ won't work, because all pairs $(m,0)$ don't have a source...
Any hints would be much appreciated!

REPLY [4 votes]: Here is a not so popular but explicit bijection from $\Bbb Q^+$ to $\Bbb N$. 
http://www.cut-the-knot.org/do_you_know/countRats.shtml
Say you have the positive rational number $t=m/n$
where m and n are relatively prime.
Say m and n have the following prime number decompositions:
$m = p_1^{a_1}p_2^{a_2}...p_r^{a_r}$
$n = q_1^{b_1}q_2^{b_2}...q_s^{b_s}$     
Then you map $t$ to this positive integer:  
$p_1^{2a_1}p_2^{2a_2}...p_r^{2a_r} q_1^{2b_1-1}q_2^{2b_2-1}...q_s^{2b_s-1}$ 
1) Prove that it's a bijection.
2) This can be easily modified to accommodate also
negative rationals and the rational zero. How?