How to check for rational number?

How to check if a number is rational or not?
In other words, how to check whether the number can be written in p/q form?

Where do you get this number from?