The integers can indeed be defined in the rational field, but not in the real field.
The question can be made precise by introducing some tools of first order logic. What you are asking about is the definability of the integers inside the rationals. For example, if you might consider the rational field structure ⟨Q,+,.,0,1⟩ and inquire whether the integers are defined by a first order order formula in this structure. That is, is there a first order formula φ(x) such that this structure satisfies φ(x) if and only if x is an integer? The answer is yes, and this paper appears to be about investigating how complex the definition is.
The fact that Z is definable in Q impies that the theory of the rational field is not a decidable theory. That is, there can be no computable algorithm which correctly tells us whether a given statement holds or fails in the rational field. The reason is that if we had such an algorithm, then by using the definability of the integers, we would be able to tell whether or not an arithmetic statement held or failed in the natural numbers, and with this, we would be able to solve the halting problem, which is impossible.
This situation contrasts sharply with the real field ⟨R,+,.,0,1⟩, whose theory IS decidable. Indeed, Tarski proved that the theory of real-closed (ordered) fields ⟨R,+,.,0,1,<⟩ is decidable. It follows that neither the integers nor the rationals are first-order definable in the real ordered field.
(Lastly, let me point out that the particular suggestions that you make for the definition are not first order definitions, and may suffer the criticism, as in some of the comments, that they beg the question concerning how the integers are implicit in your structure. The concept of first-order definability seems to avoid these criticisms, while clarifying both the question and the answers.)