Can you define a compositions of two functions whose domain and range differ? Suppose we have 2 functions $f, g$.
$$f: \mathbb{R}\to\mathbb{R}$$
$$g: \mathbb{R} \to\mathbb{Z}$$
Can the composition $f(g(x))$ be defined?
I have come across conflicting explanations in $2$ textbooks where one of them says that the requirement for a $f(g(x))$ composition is that the range of $G$ be a subset of the domain of $F$.
The other explanation says that if the range of $G$ differs from the domain of $F$ in any way, the composition cannot be formed.
It sounds logical that the first explanation is correct
 A: If $f: A \to A$ and $g:A \to B$ where $B \subset A$ then the composition $f \circ g: A \to A$ is defined as the function $x \mapsto g(x) \mapsto f(g(x))$. You should check for yourself that this is a well defined assignment.
In general if the range of $g$ is a subset of the domain of $f$ the composition will be defined properly.
A: It seems that your definitions of $f$ and $g$ conflict with your question. I think that you are asking if the composition $$g\circ f:R\to Z\qquad x\mapsto g(f(x))$$ can be defined or not. (in this way the image of $f$ is a subset of the domain of $g$).
In general, as you noticed, the image of a generic function $f:R\to R$ will be just a subset of $R$, unless $f$ is surjective. However, the composition $g\circ f$ is well defined because every output of $f$ lies in the domain of $g$ and thus can be send by $g$ to an element of $Z$. Therefore, the composition is well defined. 
Things change a bit if the codomain of $f$ is just a proper subset of the domain of $g$, i.e. if $A \subsetneq R$ and $f:R\to A$, $g: R\to Z$. In this case the composition $g\circ f$ still makes sense, even though to be completely rigorous one should restrict $g$ to $A$ and then compose the result of the restriction with $f$.
In practice, one still writes $g\circ f$, since the meaning is clear.  
