Take your body weight and X by:
8 to 10 to loose bodyfat
12 to gain muscle and loose bodyfat
15 if you want go gain muscle.
You should be eating the correct amounts of carbs and protien eg
if your body weight is 170lbs and you want to loose body fat right, then;
170 X 10 = 1700
Ok now to workout out how much % of those caloreis you want protein etc...
1700 x .40 = 680 caloreis from protein
1700 X .40 = 680 calories from carbohydrates
1700 X .20 = 340 calores from fat
This does work by the way I tried it for about a week and saw results
Good Luck