My question is, is it necessary for every element of the domain to map onto some element of the range for a function to be injective? For example, is
$$f(x) = x,\ f:\Bbb R \to \Bbb Z$$
one-to-one/injective, even though there are many elements of the reals that cannot map onto the integers? Obviously for every element that can map onto $\Bbb Z$, it is the only element that corresponds to its output, but I guess I'm wondering if this "overflow" of elements in $\Bbb R$ that don't map onto $\Bbb Z$ matter.
Another example, which is the reason I wanted to know the answer to this question:
$$f(x)= 1/x,\ f:\Bbb R \to \Bbb R \setminus \{0\}$$
So obviously, every element of the domain points to only $1$ element of the range in this function, but does it matter that when $x=0$ the function is undefined? Or does that not effect whether the function is one-to-one or not?