Previously, calories had been determined by the FDA similar to the way we did it in high school labs, with a bomb calorimeter. The food was burned all the way and the rise in water temperature was then measured. However, this is an outdated method which is not incredibly accurate.
Fast forward to the present method: In 1990 the George H.W. Bush signed the Nutritional Labeling and Education Act of 1990 (NLEA) which required most foods regulated by the FDA have nutrition information on their food label and that all nutritional claims ("low fat", "high fiber") meet the FDA regulations. This law also changed the way the calorie content of foods are determined. Instead of burning the foods, indirect calorimetry is done using the Atwater System... which basically breaks down the food into the energy containing nutrients (fat, protein, alcohol, and carbohdyrate). Fat= 9 kcal/gram, Protein= 4 kcal/ gram, Alcohol= 7 kcal/gram, and Carbohydrate= 4 kcal/gram. Knowing the calorie content per gram of macronutrient, scientists are able to calculate the caloric content of foods. This system is much more complicated than I will explain, but it gives a pretty good idea of the total available calories in a food... the human digestive tract is very efficient and will obtain most of the calories present (unless high amounts of dietary fiber are consumed).
I hope this little science lesson makes you more aware of where the calories come from in your food, I would go into much greater detail of how they determine the specific amount of each macronutrient (e.g: Nitrogen content -> protein estimation), and digestibility calculations, but I don't want to bore you.
***EXCITING NEWS!!!: If you are a member of the Independence Blue Cross Personal Choice PPO Plan, you can have 6 free nutrition counseling sessions with me over the course of a year! To schedule an appointment, email me at: firstname.lastname@example.org