There are three different ways of describing elevation gain/change for hikes.
The least useful – and sadly a very common – method is simply to subtract the starting elevation from the ending elevation. This should be called the net elevation gain and mathematically is identical to the sum of the gains, 1000m in your example, minus the sum of the losses, 500m, yielding a net gain of 500m. Since many hikes are round-trip hikes, returning to the starting point, the net gain for the entire hike is always zero. The lazy guidebook writer or trail website contributor will use this method but it has limited value.
The most useful method is to provide the total gains and total losses for any hike. For a one-way hike, your example has a total gain of 1000m and a total loss of 500m. For a round-trip – and assuming the return trip follows the same route – your total gain is 1500m and the total loss is 1500m. Yes, the overall net gain is zero but you have gone up and down a lot. Trail descriptions that go to the trouble of summing all the ups and downs are very beneficial.
Of intermediate use is the "wikipedia" method that Charlie cites: only quote the total gains and ignore the total losses. For a one-way hike, your example has a total gain of 1000m. For the return trip, assuming the same route, you now need to sum what were losses (500m) but are now gains. So your round-trip has a total gain of 1500m. The only use for this method that I can think of is for backcountry skiing where the uphill is hard work and the downhill is all fun and games.
Of course, if the net gain (1000m) and total gain (500m) are both given, then the total loss (500m) is found by simple subtraction.