If you've held a stock investment for a long time, chances are you've received dividend payments or had the stock split at least once. If so, when you sell the stock, figuring your capital gains gets complicated. Stock splits don't change your total basis, but they do affect the basis per share. Dividends don't affect the basis for your existing shares, but if you reinvest those dividends, your purchase price for the shares sets your basis for them.

Calculate the total cost to purchase the stock by adding the purchase price to any transaction fees. For example, if you bought 400 shares of stock for $3,980 and a $20 transaction fee, your total basis is $4,000.

Divide your total basis by the number of shares purchased to find your original per-share basis. In this example, divide $4,000 by 400 shares to find your basis is $10 per share.

Divide your per share basis by the number of new shares you received for each old share in a stock split to figure your new basis after each stock split. For example, if your stock splits 2-for-1, divide your old basis of $10 per share by 2 to get a new basis of $5 per share. If your stock later does a reverse stock split, where you get one new share for every four old shares (or 0.25 new shares for one old share), divide the basis of $5 per share by 0.25 to find the new basis is $20 per share.

Use the purchase price of any new shares bought with reinvested dividends as the basis for those shares. For example, if you receive $44 in dividends and use it to purchase two new shares, your basis for each of those shares is $22 per share.

Calculate your net proceeds from the sale by subtracting any transaction costs from the selling price. For example, if you sell 100 shares for $2,320 but pay a transaction fee of $20, your net proceeds are $2,300.

Divide the net proceeds by the number of shares sold to find the price per share. In this example, divide the $2,300 net proceeds by 100 shares to find the per share proceeds equal $23.

Subtract your basis for each share sold from the sales price to figure your gain per share. Unless you specify shares to be sold, the IRS treats you as selling the shares you've owned the longest first. In this example, if each of the 100 shares has a basis of $20, your capital gain is $3 per share, or $300.

#### Tip

- If you're selling all of your shares, you can simply subtract your basis from your net proceeds to figure your capital gain because you're using up all of your basis in the sale.

#### Photo Credits

- Comstock/Comstock/Getty Images

**MORE MUST-CLICKS:**