How do you calculate the gain or loss when an asset is sold?