The P/E ratio divides the share price by earnings per share. Investor.gov (SEC) describes it as a way of gauging whether a stock's price is high or low compared with its own past or with other companies, and defines EPS using the earnings for the past 12 months.
P/E = share price ÷ EPS
Earnings yield = EPS ÷ share price (the inverse, handy for comparing with bond yields)
Trailing P/E uses the last 12 months of reported earnings; forward P/E uses analysts' estimates for the next 12 months, which can turn out wrong.
Example (fictional company)
Acme Widgets trades at $85 and earned $4.25 per share over the last 12 months. P/E = 85 ÷ 4.25 = 20.0×, and the earnings yield is 5.00%. If you think 12–25× is a reasonable range for this business, the matching prices are $51.00, $76.50 (at 18×) and $106.25. At $85 the stock is 11.1% above the middle estimate.
How to use P/E sensibly
Compare like with like: fast-growing sectors usually trade at higher multiples than slow-growing or cyclical ones.
Watch the "E": one-off gains or write-offs can make earnings, and therefore P/E, look unusually low or high.
Negative earnings make P/E meaningless; the calculator flags this instead of showing a negative number.
Cyclical companies often look cheapest (lowest P/E) at the peak of their earnings cycle.
The valuation range you enter is your own assumption. Nothing here is a recommendation to buy or sell.