Is the value listed for a gem its buying price, selling price, or something else?
Gems are listed with a value in the DM Guide as treasure. In this context, it would imply the gem could be sold for that number of gold pieces.
Gems worth particular amounts are also mentioned in the Player’s Handbook as material components for spells, where one might assume that is the (approximate) price in gold pieces to buy the specified gems.
Imagine a wizard finds a 40 GP diamond among some treasure. He sells it to a gem merchant and then buys a 50 GP diamond to use as a material component. (Our honest gem merchant needs to charge a reasonable margin to stay in business.) The wizard checks out his new purchase — could he be looking at the same darn diamond?