system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How are calories in food worked out and how accurate are they?

I was just at Subway ordering a 6inch Melt when it occurred to me; who the hell can say with such confidence that my sub had 392 kcals in it?
gpt
They use a bomb calorimeter.

Basically they burn the food inside a sealed chamber surrounded by water, then measure how much the water is heated up.  That tells you the energy content of the food.

For your sub, they didn't measure it directly, they instead added up the caloric content of the ingredients.  This is scaled by the quantity of any given ingredient.

For hand made food such as sandwiches, it's not very accurate.  You can assume +/- 10%, easily.