No doubt about it, doing a tax return is a hassle. All those 1099 forms, the W-2 and the task of computing work-related and charitable deductions can make you want to bang your head on the desk.

But all that’s the easy part. For many people, the biggest challenge is computing capital gains and losses on investments. While most other tax-return issues involve events of the past year, calculating capital gains can require records going back decades.

And the stakes are high. Faced with big budget deficits, some members of Congress want to tighten up on capital gains reporting, arguing that the government is missing out on tens of billions of dollars of taxes due every year. The push could turn into new reporting standards when stocks and other investments are purchased, and there may be more audits.

Even without this new worry, capital gains calculations deserve close attention because a mistake is as likely to make you pay too much tax as too little.

**The basics**Capital gains are the profits earned when you sell an asset for more than you paid — the "cost basis." The difference is subject to either a short- or long-term capital gains tax. (This generally does not apply to to assets held in tax-favored accounts like 401(k)s and IRAs.)

Sell a stock, mutual fund share or other asset you’ve owned longer than 12 months and you’ll owe a maximum of 15 percent tax on the profit. Sell the same investment 12 months or less after buying it and the profit is taxed as a short-term capital gain, at a rate as high as 35 percent.

Losses are figured the same way — by subtracting the cost basis from the sales proceeds to get a negative number. Losses can be subtracted from gains on other investments you sold to create a net gain or loss for the entire year. If losses exceed gains, the extra loss can be used to reduce your taxable income by up to $3,000 a year. Larger losses can be “carried forward” and used to offset capital gains or income in future years.

Sounds easy enough. The sales all too place in 2007, and brokerages provide summary statements by the end of January. The real problem is finding and using the correct cost basis.

If you used the same brokerage to buy and sell the asset, the firm probably will have this figure. But in many cases you may need to dig back through your records to find the purchase price.

For inherited stocks or other assets, the cost basis is the price on the day the previous owner died. If assets are received as a gift, your cost basis is the same as the giver’s.

Several things can make the cost calculation even more complicated.

**Partial-sales math**First is when you sell a block of shares that were bought over time at various prices. In this case, add up the total paid over the years for all the shares you sold, then subtract that from the sales proceeds. The result is the capital gain or loss.

What if you sell just some of the shares?

The easiest approach is to figure the average price paid. Tally all the money spent on shares over the years and divide by the number of shares you had before the sale. The result is an average cost per share. Subtract this from the sales price per share to figure the profit on each share, then multiply the result by the number of shares sold.

This way, you can use the same purchase price if you sell another batch later.

When just part of a holding is sold, many investors prefer to minimize any capital gains tax -– or maximize their tax loss. They do this by selling the shares for which they paid the highest price, leaving the smallest possible profit (or biggest loss).

If you want to sell a specific block of shares, the IRS requires that you give this instruction to your broker or fund company when you order the sale, and that you get written confirmation.

Selling specific blocks of shares means you must have good records in case the IRS asks you to prove the cost basis you use.

A second troublesome area involves accounting for shares that were purchased over the years with reinvested dividends and capital gains distributions.

Dividends and capital gains distributions are taxed for the year they are paid out. The maximum dividend rate is 15 percent, while capital gains distributions are taxed at either the long- or short-term capital gains rate, depending on how long the fund owned the assets it sold.

These payments to shareholders are taxable in the year they are made, and investors need to be careful not to be taxed twice. That happens if you forget about these payments when you figure gains after selling your fund shares.

Dividends and capital gains distributions used to buy more shares are *added* to the cost basis.

Imagine that five years ago you bought 100 shares of the XYZ mutual fund for $10 each. Your cost basis would be $1,000.

Now suppose the fund made dividend and capital gains distributions of 50 cents a share for each of those five years, and that you paid tax on that money while using it to buy more shares. The $2.50 earned by each share is added to your cost basis.

To keep it simple, let’s assume you’d received $250 from these payments and used it to buy 15 more shares as the price rose over the years. Now you have 115 shares bought for $1,250 – the original $1,000 plus $250 in reinvested distributions. If you sold the whole lot for $2,000, your taxable gain would be $750, rather than the $1,000 that, at first glance, appears to be the difference between your sales price and purchase price.

**Accounting for splits**Now for a third problem: Stock splits. This is when a company issues a new share for every share already in circulation. If you had 100 shares worth $10 each, a split might leave you with 200 shares worth $5 each.

If you sell the entire holding, accounting for splits is no problem. Just take what you originally paid, add all the reinvested dividends and capital gains and then subtract the result from what you received in the sale.

But if you sell just some of the shares, start by adding up all the money spent on shares from your original purchase and subsequent ones, plus reinvested dividends. Divide the result by the number of shares you had just before the sale to determine an average cost per share. Use that to figure your taxable gains per share, and multiply the result by the number of shares sold.

You could, of course, tell your broker to sell the shares bought at the highest prices. But to figure your gain or loss you’ll need very detailed records of the price paid for every share — adjusted for the split.

**Getting help**Mutual fund companies generally have good records of cost basis and gains because their funds are controlled in-house. Reconstructing cost basis on a stock can be difficult, as your current broker may not have all the data you need.

In this case, go to the Web site of the company that issued the stock. Many companies’ investor relations departments provide details on cost basis which account for events like splits, mergers and acquisitions and spin-offs.

If the company doesn’t have the information you need, check the BigCharts free service for historical quotes. NetWorth Services, CCH, and other firms sell cost-basis research services.

Yes, all this can be a headache. But failing to do it may leave you paying more tax than you should.

All the more reason to start your return early.