Proof of one-to-one and onto for a function Im having a bit of trouble with the following question:
let $f:R\rightarrow \mathbb{Z}$ be the function where for each $x\in R$, $f(x)=\lfloor 2x \rfloor$.
a) Is f a one to one function?
I.E. $\forall x \in R$, $f(x_1)=f(x_2) \implies x_1 = x_2$)
Proof by counter example:
let 
$x_1=\frac{1}{2}$   
$x_2=\frac{3}{4}$   
now substitute into $f(x)$: 
$f(1/2)=\lfloor 2(1/2) \rfloor = 1$
$f(3/4)=\lfloor 2(3/4) \rfloor = 1$
so $f(1/2)=f(3/4)$ but $x_1 \neq x_2$ so not one to one
b) Is f an onto function?
$f:R \rightarrow \mathbb{Z}$ is onto if and only if $\forall x_2\in Z,\exists x_1\in R$ such that $f(x_1)=x_2$ 
Proof: 
f($x_1$)=$\lfloor 2(x_1) \rfloor$=$x_2$
$\lfloor x_1 \rfloor$ =$x_2/2$ (this is as far as i got before my train of thought hit a brick wall)
can someone please help me understand the last bit of this question? the part thats confusing me is that im unsure about how to solve when a floor or ceiling is involved. Also Im pretty sure my proof for part a) is correct but if not it would be a huge help if you could correct me where ive gone wrong.
-thanks
 A: This is what I came to for part b
to prove that f is surjective, $\forall n \in \mathbb{Z}$,  a real number $x$ is needed such that $n=\lfloor 2x \rfloor$:
dividing both sides by 2:
$\frac{n}{2}=x$
substituting back into f:
$n=\lfloor 2(\frac{n}{2}) \rfloor$
$n=\lfloor n \rfloor$
since n is an integer and also a real number and the floor of an integer is always that same integer, the function f is surjective/onto.
is this correct? if not can someone please correct me
A: You are correct about part a). 
For $f$ to be an "onto" function, as you put it (we call that "surjective" most of the time), you need that every element of $\mathbb{Z}$ gets mapped to by your function $f$ (your definition of "onto" as you put in your question, is incorrect). 
$\mathbb{Z}$ only contains the integers. Can every integer be mapped to by your function $f$? If not, can you find a counter example? If so, you need to prove it! The best way to try to prove something like that is to consider an arbitrary integer, say $k$, and prove that it can be mapped to by $f$.
