What is the formula used to calculate energy content of food?

The Atwater general factor system is the formula used to calculate the energy content of food. Here is the formula:

Caloric Value = (g protein x 4) + (g carbohydrates x 4) + (g fat x 9)