How are the calories in food calculated? This is intended to be a fun question.  Calorimetry used for calculating the heat generated from chemical changes has been around for centuries, however, I suspect the process for calculating food calories is much more complicated.  Can anybody provide a clear succinct, knowledgable answer?  Although I will accept answers with links, an independent answer would be preferred.
 A: There's a few different ways of defining what you mean by 'Calories' in food.  There's the obvious physical/chemical definition of energy stored in the food, but I had an objection when I explained that warmer food naturally has more Calories than cold food.  There's also the measure of absorbtion, or 'digestibility', which can be determined by what nutrients pass through the body unabsorbed.
The US FDA has guidelines that basically suggest for their labeling requirements, it's based on estimates of calories in the component parts of the food:

L12. Is it necessary to include a calorie conversion footnote which states that fat, carbohydrate, and protein furnish 9, 4, and 4 calories per gram, respectively?
Answer: No, the use of that footnote is optional. 21 CFR 101.9(d)(10)

But they also have rules on rounding:

L31. What are insignificant amounts of nutrients?
Answer: These are the amounts that are permitted to be shown as zero on the Nutrition Facts label (e.g., less than 5 calories may be expressed as 0 calories) except that for total carbohydrate, dietary fiber, and protein, it is the amount that can be declared as “less than 1 g” on the Nutrition Facts label. 21 CFR 101.9(c)

It seems that less than 0.5g is required to be listed as '0g', even though they call for rounding at other times:

L45. How should trans fatty acids be listed?
Answer: Trans fatty acids should be listed as “Trans fat” or “Trans” on a separate line under the listing of saturated fat in the Nutrition Facts label (see figure). The word “trans” may be italicized to indicate its Latin origin. Trans fat content must be expressed as grams per serving to the nearest 0.5-gram increment below 5 grams and to the nearest gram above 5 grams. If a serving contains less than 0.5 gram, the content, when declared, must be expressed as “0 g.” (21 CFR 101.9(c)(2)(ii)).

...
Some items are allowed to take into account absorbtion (eg, Olestra, the fat that humans can't absorb), but there's also personal differences -- not all people absorb nutrients the same way, due to food intollerances.  There's also the question of how cooking affects absorbtion, as some studies have shown different digestibility between cooked and uncooked items.  Of course, nutrition labels don't have a way to explain that there's different effective Calories depending on how something's prepared.
Personally, I go with the assumption that they're inaccurate estimates.  It's my understanding that the FDA doesn't even care unless the values are more than 20% off.  As such, there's no incentive for companies to test their product -- if they found out their values were wrong, they might be forced to correct them, and doing so could put them at a disadvantage to other groups that were 19.5% wrong in their values.  Also, as most food products are agricultural, there's going to be differences between tomatoes from one plant to another, and they just average these things out ... but we have no idea what the variance is for any of the values.
update : Looking at what I wrote, I don't think I was really clear on the different perspectives of what 'Calories' in food are:


*

*physics : total energy (chemical potential + thermal)

*chemistry : potential chemical energy only

*biology : chemical energy of the nutrients that were absorbed

*"food science" : an estimate of chemical energy that's likely to be absorbed by a human

*US FDA : really inacurate numbers vaguely related to the "food science" perspective

A: a great question. First, a detail: a person needs something like 2,000 kilocalories a day. At least that's how the unit is used today; in the past, the modern kilocalorie used to be called a calorie. Today, 1 kcal equals 4.182 kilojoules. 
Ideally, one could measure the kilocalories by direct calorimetry, i.e. in a bomb calorimeter. However, that would also burn some portions of the food that are not burned by the humans - as demonstrated by the fact that we sometimes need to use the restrooms to deposit some solids (with dietary fibers etc.) as well.
The dietary value is only encoding the energy that can be extracted from the food by humans. So it is assumed that we can only get the energy from several basic "elements of food", namely fat, ethanol, proteins, carbohydrates, organic acids, polyols (sweeteners, sugar alcohols), fibre, and erythritol.
Each food is chemically analyzed and the amount of these components is quantified. By multiplying the weight of each component by the "energy density" (for example, it's 9 kcal/g for fats), we obtain the kcal figure for the food. 
I suppose that these standardized figures - such as 9 kcal/g for fat - have been obtained by observing people's motion and heat for some time but I am actually not quite sure whether they were feeding someone with pure fat for some time haha. Someone may know an answer to this sub-question.
Best wishes
Lubos
A: The "calories" in food used to be measured using a bomb calorimeter: the food is burnt, one measures how much heat that produces. This is confirmed by "for dummies" and more believably by this publication from Fisher Scientific who make bomb calorimeters for this purpose - so they should know.
On the other hand, this article in Scientific American (written by a food scientist) says that since 1990 the method prescribed in the USA (by the Nutrition Labeling and Education Act or NLEA) is based on food composition - with the values used for carb, protein, fat derived from bomb calorimeter measurements (but obviously approximate).
The reason for this is that the bomb calorimeter does not always give you the nutritional calorie count - whether the body can actually extract these calories. Fiber for example is a typical case: depending on the type of fiber, and your precise gut flora, you may be able to extract more or less energy from certain kinds of fiber. But fiber burns and creates calories (think wood).
