Start with what people are paying for the company, by finding the market cap of the stock. Ex: GOOG = $289B Now that you know what people are paying for it, what is it actually worth? Simplified value of company = present assets - present liabilities + future earnings, discounted to present values Using these two values (market cap=$ people are paying, and company value=$ it is worth) we can now re-frame your original question. Overvalued companies are those where market cap>company value (people paying more for it than it's worth) and undervalued companies have the opposite relationship, company value>market cap.
Having established that, let's examine how to calculate company value. To reiterate, company value = present assets - present liabilities + future earnings. So there's a present component, and a future component. Let's look at the present component first.
You can find the company's assets and liabilities on its balance sheet, for GOOG, present assets = total assets - goodwill - intangible assets = $78B. Goodwill and intangible assets are removed because they're often imprecise due to being semi-imaginary. Again for GOOG, present liabilities = total liabilities = $21B. So GOOG has tangible assets less total liabilities of $78B-$21B=$57B. Let's go ahead and subtract that from the total market cap, $289B, to get $232B - the future value of GOOG required to justify its value. Future values are uncertain, and therefore are purely estimates. A number of other posts here have given good methods for exploring future revenues/cash flows, so I'll continue to give the big picture. What is GOOG earning? $16.6B cash from operations. Where is that money going? $3.2B to capital investments + $0.3B in share buybacks, and the rest is retained within the company. So $16.6B-$3.2B-$0.3B = $13.1B earned per year at current returns.
Now let's divide the $232B "future value" of GOOG (market cap - present value), by $13.1B to find out how many years it'd take to earn that future value back: 17.7 years. Alternatively, you can divide it the other way to see that each year at $13.3B you're earning 5.6% of the future value. That's pretty decent, but is it fair? Well, it largely depends on what your opinions of GOOG's future prospects are. If you think its growth over the next 17 years will outpace inflation, then you'd likely earn a nice return on it. On the other hand, if you fear too many people taking the Bing challenge and being driven off of cliffs by driverless cars then it would be a bad investment. What we can definitely say is that 5.6% is a reasonable starting point. Not cheap, but also not insanely low.
I'll go ahead and close this with a few notes of caution - most of the companies you'll find that look very very cheap based on these quantitative criteria have very negative qualitative criteria associated with them. This method is best applied to companies you already like, but are unsure whether the price is right.