"I work out so I can eat whatever I want."

Consider those the famous last words uttered by formerly thin guys everywhere.

"A lot of people think if they eat an extra 300 calories they can work it off, but that's not the case," says Holly Lofton, M.D., director of weight management at NYU Langone Medical Center.

RELATED: The Only 5 Exercises You'll Ever Need

Why? Well, while exercise can certainly help mediate the damage done by a less-than-healthy diet—granted you have a job and a life outside of the gym—there aren't enough hours in the day to work off the foods that a lot of guys eat in the name of that mindset of It's OK, I just worked out. Hence why even though the number of people meeting their exercise guidelines is rising, so is the number of people who are obese, per University of Washington research.

RELATED: 14 Healthiest Snack Foods to Buy

Part of that's because most people tend to greatly underestimate the number of calories they're eating. Meanwhile, they overestimate how many calories they are burning in the gym. (Find out how accurate your fitness tracker and cardio machine's calorie counter are.) Meanwhile, it takes a lot more effort to burn calories than take them in.

RELATED: Shirtless Nick Jonas Explains How He Got His New Body

"That extra large beef burrito you scored on the way home from the gym packs more calories than the amount you torch during an hour working out," explains Samantha Cassetty, M.S., R.D., vice president of nutrition for Luvo.

But trying to out-exercise a junk food diet is about more than calories in versus calories out, Lofton says. 

RELATED: The Squat-Free Way To Build A Strong And Lean Lower Body

"The body is complex and hormonal factors can have a large influence on weight gain and loss."

For instance, when you eat a sugary donut, soda, or waffle, your body's levels of insulin rise, which in turns switches your body into fat storage-mode, she says. So you aren't just eating X number of calories. You're basically injecting X number of calories straight into your ever-expanding fat cells.

RELATED: The Hottest Vanity Muscles—And How To Get Them

Plus, eating a lot of unhealthy foods promotes inflammation, which research published in the journal Diabetology & Metabolic Syndrome suggests can lead to weight gain all on its own.

"The stress response causes your body to hold onto calories and store them, rather than use them for fuel," says sports nutritionist Susan M. Kleiner, R.D., Ph.D., a scientific consultant with USANA Health Sciences. "Plus, with the inflammation, you are getting more sore from your workouts and you don't really want to train hard." So even if you feel like you're hitting the gym hard, you probably aren't burning as much fat as you'd need to counteract the effects of a junky diet.

RELATED: 5 Exercise Machines You Should Never Use at the Gym

The bottom line: "When it comes to sculpting your body and enhancing your performance, without a diet to support your training you are wasting your time in the gym," Kleiner says.

Click for more from Details.