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 simply buy any 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 what would be the right decision to make.

Unfortunately, this isn't a perfect world. We're forced to pay a broker for access to the market, and to pay the Securities and Exchange Commission for maintaining an orderly and fair playing field. Plus, if we manage to make a profitable trade, the federal and most state governments also 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 iPod maker Apple (NASDAQ:AAPL) in mid-May of last year, when it could have been picked up for less than $35 a share. In your foresight, you knew, better than the market did at the time, that Apple was really worth about $70 a stub. Eventually, the market woke up to your superior analysis and rocketed Apple's shares skyward, more than doubling your investment in just a few months. Recently trading around $76, however, Apple 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 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. After paying your taxes of $11.79, let's assume that you have $64.21 remaining after selling your share of Apple stock [$76 minus $11.79]. Your choice really becomes "Would I rather hold a $70 company trading at $76, or would I rather have about $64 in cash?"

Personally, I won't normally sell a company unless I can keep more than I think it is worth. In this example, I'd need an amount subtantially greater than $70 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 a primary reason why my wife still owns her shares of mall operator General Growth Properties (NYSE:GGP) despite its spectacular run since she purchased it last March. While its shares now appear fully valued, her costs of selling would knock down what she'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 pharmaceutical giant Pfizer (NYSE:PFE) as being worth about $31 a stub. Yet just by adjusting things a tiny bit, that number can change radically in either direction. You can see this effect for yourself, looking at that business using Inside Value's online cash flow calculator, available here for subscribers (if you're not yet on board, click here to start your 30-day free trial).

This is why it's so important to understand the business behind the stock, so that the numbers you use make realistic sense for the company. For instance, last June, I built a related model to calculate that banking giant Bank of America (NYSE:BAC) was worth about $46.72 a share. A minor tweak upward in my assumed growth rate could easily have shot my fair value estimate past $50, and a bit more pessimism would have knocked it down to around $42. Until recently, it had been performing right in line with my expectations. Thanks to still-rising short-term interest rates, however, the bank is likely to see a bit slower growth than I had originally projected. If that happens, the more pessimistic projection would likely better reflect reality.

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 that 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 Cisco Systems (NASDAQ:CSCO) basher, I do believe the networking giant is worth something. Specifically, I think it's likely worth somewhere between $14 and $17 a share, based on a discounted cash flow analysis. To get a margin of safety on the buy side, I'd be willing to buy if its shares dropped below $11.20. That's 20% below the low end of what I think the company is worth.

Conversely, if I happened to already own Cisco, I wouldn't be selling it unless I could keep at least $20.40 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 around $24 to end up keeping that much. While this means that I wouldn't be buying Cisco at its recent price of around $18.50, 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 just 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 you'll also receive a copy ofStocks 2006, the Fool's guide to the investing year ahead, absolutely free.

At the time of publication, Fool contributor and Inside Value team memberChuckSalettaowned shares of Bank of America, which is anIncome Investorrecommendation. At the time of publication, his wife owned shares of General Growth Properties. The Fool has adisclosure policy.