In a perfect world, we'd know exactly what every company is worth. In that same world, we'd also be able to exchange cash and shares without worrying about friction costs like commissions, taxes, and SEC fees. With that perfect knowledge and cost-free trading, market-beating investing would be simple. We'd just buy a company if it traded below its fair value, then turn around and sell it if it jumped past that level. And because we would know a firm's exact worth, there'd never be a question about making the right decision.

Unfortunately, this isn't a perfect world. We're forced to pay a broker for access to the market, and we're forced to pay the SEC for maintaining an orderly and fair playing field. Plus, if we manage to make a profitable trade, the federal government and most state governments expect a cut of the profits. Because of these costs, investment moves that would have made sense in a perfect world often don't make sense in ours.

For example, imagine you bought computer chip maker Advanced Micro Devices (NYSE:AMD) in early May of last year, when it could have been picked up for about $14.50 a share. In your foresight, you knew -- better than the market did at the time -- that AMD would keep its technological lead over archrival Intel (NASDAQ:INTC) for longer than expected. Confident in your analysis, you pegged AMD's value at $37 a share. Eventually, the market woke up to your superior analysis and rocketed AMD's shares skyward, more than doubling your investment in just a few months. Recently trading at about $41.33, however, AMD is now priced higher than you think it's worth. In a perfect world, you'd want to take advantage of its high price and sell.

Friction burns
In our world, however, you also have to consider how much you'd keep after factoring in all costs of selling. Say, for instance, that you're in the 25% federal and 5% state tax bracket, and that you itemize your taxes. By selling, you'd have a short-term capital gain of about $26.83 a share, and you would owe about $7.71 in taxes. After paying those taxes, you'd end up with about $33.62 a stub. Here's your new predicament: Would you rather hold a $37 company trading at $41, or would you rather have some $33 and change in cash?

I typically won't sell a company unless I can keep more than I think it is worth. In that example, I'd need an amount substantially greater than $37 after taxes to make selling worthwhile. Why pay my broker and the government only to end up with a result worth less than had I done nothing? That's the primary reason why I still own my shares of distiller and specialty grain producer MGP Ingredients (NASDAQ:MGPI), despite its approximate 65% run since I purchased it in February 2005. While its shares now appear fully valued, my costs of selling would knock down what I'd keep to less than what the business is worth.

Reply hazy? Try again
In addition to the costs of selling, no matter how thorough our valuation models, they're all based on projections and estimates of the future. Slight changes to our assumptions could have dramatic effects on what we think the business is really worth. In his evaluations, Motley Fool Inside Value analyst Philip Durell uses a technique known as a discounted cash flow calculation to find bargains for subscribers. Using that method, last year he pegged industrial giant 3M (NYSE:MMM) as being worth about $92 a stub. Yet just by adjusting things a tiny bit, that number can change radically -- for the good or the bad. You can see this for yourself using Inside Value's online cash flow calculator, which is available here for subscribers (if you're not yet on board, click here to start your 30-day free trial).

It's important to understand the business behind the stock. That way, the numbers you use make realistic sense for the company. For instance, in late 2004, I built a related model to calculate that insurance firm Presidential Life (NASDAQ:PLFE) was worth about $17.88 a share. A minor tweak upward in my assumed growth rate could easily have shot my fair value estimate past $20, and a bit more pessimism would have knocked it down to about $15. While the company's dividends haven't grown as quickly as I had hoped, its overall financial picture has gotten stronger, pulling my valuation estimate up along with it.

Your weapon against uncertainty
Fortunately, value investing pioneer Benjamin Graham came up with a solution to this conundrum, which he called the margin of safety. To use Graham's margin, make your best projection of a company's true worth, then knock off a decent chunk from that value. If the firm's stock is trading below even the discounted price, then it's time to buy. On the flip side, the time to sell is when that stock is trading so far above its true worth that you'd keep a margin above the highest value you could realistically calculate for the business.

To illustrate, while I've often been accused of being a TASERInternational (NASDAQ:TASR) basher, I do believe the stun gun maker is worth something. Specifically, I think it's likely worth somewhere between $6 and $8 a share, based on a discounted cash flow analysis along with the presumption of a decent business recovery. To get a margin of safety on the buy side, I'd be willing to buy if its shares dropped below $4.80. That's 20% below the low end of what I think the company is worth.

Conversely, if I happened to already own TASER, I wouldn't be selling it unless I could keep at least $9.60 from the transaction. Not surprisingly, that's 20% above the high end of what I think it's worth. Thanks to brokerage commissions, SEC fees, and taxes, I'd probably need to sell it at about $12 to end up keeping that much. While this means that I wouldn't be buying Taser at its recent price of $9.94, I wouldn't be selling it right now, either. It's simply too close to its fair price to be worth the total costs of a transaction.

The Foolish bottom line
In the end, it's what you keep after all costs that really counts. Your job as an investor is to maximize your net worth. To do that, you must be focused on buying low enough to get a discount to a company's fair value and selling high enough to keep a surplus above its true worth. In between those prices, any moves might cost you more than they're worth.

Do you like the idea of using both a company's true value and what you'll keep when all is said and done to tell you when to buy and when to sell? Take a free trial of Inside Value and see how it's done. Subscribe today, and we'll knock $50 off the regular price and send you a copy of Benjamin Graham's masterpiece The Intelligent Investor,absolutely free.

This article was originally published on Feb. 3, 2006. It has been updated.

At the time of publication, Fool contributor and Inside Value team memberChuckSalettaowned shares of Presidential Life and MGP Ingredients. TASER is a Rule Breakers recommendation. The Fool has adisclosure policy.