2 ways;
1. If you know the ingredients of a product and their nutrimental value then you can simply do math. This is the case for most products
2. A calorimeter, basically you burn the food in a machine with water around, and you see how much the water increased in temperature. The unit calorie is derived from this method, it is the energy needed to heat up 1ml of water by 1 degree Celsius. This is typically done for food where you can’t really know what its made of, like a fruit or vegetable.
Latest Answers