TITLE: What's the bijection between reals and infinite sequences of integers?
QUESTION [12 upvotes]: In Descriptive Set Theory we often see the notion of encoding a real as a sequence of integers or natural numbers -- i.e. there obviously is a bijection according to ZF axioms. But how does it look like concretely? Anybody has seen a simple construction?
My own approach is by chain-fractions:
Let $q\in\mathbb{R}$ be the given real and now define the sequence $(z_i,q_i)$ by $$z_{i+1}=\begin{cases}[q_i]&\text{if } \{q_i\}\leq\frac{1}{2}\\
[q_{i}]+1&\text{else}
\end{cases}$$
$$q_{i+1}=(q_i-z_{i+1})^{-1}$$
where $[q]$ is the next lower integer and $\{q\}=q-[q]$. (Hence $(q_i-z_{i+1})\in(-\frac12,\frac12]$ thereby absolute value of $q_{i+1}$, its reciprocal, is bigger than 2.) Now my bijection is mapping $q$ to the sequence:
$$m_i=\begin{cases}z_i-2&z_i>0, i>1\\
z_i&i=1\\
z_i+2&z_i<0, i>1\end{cases}$$ with $i$ starting at 1 and above $q_0$ becomes the initial $q$. And the inverse of my bijection just calculates the chain-fraction:$q_{i-1}\in(z_i-\frac12,z_i+\frac12]$ with $q_{i-1}=z_i+q_i^{-1}$ step-wise narrowing down the real by a sequence of intervals each containing the next.
is there a paper or book covering my example? any other simple constructions?

REPLY [43 votes]: [Note: this answer uses the convention where $\mathbb{N} := \{ 0, 1, 2, \dots \}$ contains zero.]
There's an elegant explicit order-preserving bijection between the Baire space $\mathbb{N}^{\mathbb{N}}$ (under lexicographical order) and $\mathbb{R}_{\geq 0}$ (under the usual order) described here.
In particular, we define the image of:
$$ (a_0, a_1, a_2, a_3, \dots) $$
to be the generalised continued fraction:
$$ a_0 + \cfrac{1}{1 + \cfrac{1}{a_1 + \cfrac{1}{1 + \cfrac{1}{a_2 + \ddots}}}} $$
This order-preserving bijection shows that $\mathbb{R}_{\geq 0}$ and $\mathbb{N}^{\mathbb{N}}$ are not only isomorphic as sets (i.e. equinumerous), but also isomorphic as totally-ordered sets.
Topologically, this bijection from $\mathbb{N}^{\mathbb{N}}$ to $\mathbb{R}_{\geq 0}$ is continuous, meaning that every open subset of the nonnegative reals corresponds to an open subset of Baire space. The converse is not quite true (if it were, the two spaces would be homeomorphic, which they're not); continuity of the inverse map fails exactly at the positive rationals.