Carl
Level 15

Deductions & credits

In the tax year you sell:

Take your cost basis, and from that subtract the total amount of all depreciation taken on the property. This gives you your adjusted cost basis.

Subtract your ajusted cost basis from your sales price. This gives you your gain.

From your taxable gain subtract your sales expenses. This gives your taxable gain.

Then

If you qualify for the exclusion, subtract from that gain the total of all depreciation taken on the property. This gives you the amount exempt from taxes.

The recaptured depreciation is taxed "no" "matter" "what". It is not included in the 2 of 5 exemption rule.

Now if you have losses left to carry over to ordinary income, then you didn't sell at a gain and the "2 of last 5" is a moot point.