The calculation for a capital gain or loss is straightforward: it starts with the selling price of your capital asset minus its cost basis (what you originally paid for it).
If the number is positive (in other words, you made money on the sale), that's your capital gain.
On the other hand, if the number is negative (you lost money), you have a capital loss, unless the item is personal-use property, which can never be deducted as a capital loss.
Your net capital gain/loss is calculated by subtracting your capital losses from your capital gains (Schedule D). If you have a net capital loss, you can deduct up to $3,000 ($1,500 if Married Filing Separately) per year as a capital loss. If your net capital loss is more than the yearly limit, you can carry the loss to next year's return as a capital loss carryover.