You already know you need to drink H20 before a super-sweaty exercise session, but determining the right amount can be tricky. Plus, leaving class with a headache, feeling thirsty during a workout, or feeling like you drank too much water can be a total downer. That's why we wondered: How much is the right amount to drink and when?

The best way to keep your legs-and not head-spinning during a humid spin class: Start out well-hydrated. Try to throw back 16 ounces of water within 30 minutes of beginning your workout. "If you haven't peed in the last few hours, then you're probably a little dehydrated," says Brendon McDermott, Ph.D., an athletic trainer and assistant professor of kinesiology at the University of Arkansas.

And to figure out the best way to replenish liquid loss post-workout, there's a little math involved, says McDermott. First, weigh yourself (in kilograms, not pounds) before and after your exercise session, sans sweaty clothes. Then, take that difference in body weight and add to it how many liters of fluid was consumed during your workout. Finally, divide that number by the duration of the class (in hours) to get your sweat rate, which is also the recommnended rate of consumption.

For example, if you weigh approximately 70 kilograms (about 155 pounds) at the start of a Bikram class and drop to 68 kilograms by the end, you've lost two kilograms. So two plus half a liter of water (consumed during class) is 2.5 kilograms. Divide that by the time of 1.5 (90 minutes for the class) and that will tell you how many liters you need to take in during the next Bikram session-1.6 liters.

If this math is making you feel dizzy again, you can use Gatorade's handy fluid loss calculator to figure out how to keep your body feeling quenched when breaking a sweat in Sahara-like workout conditions. Once you know how much you lost, aim to drink 100 to 150 percent of that amount of liquid (everything but booze counts) within four to six hours post-exercise.

Also, it's weird, but true: Feeling lightheaded during a sweaty Bikram class or steamy spin session isn't always a sign of dehydration-it could also mean that you're over-hydrating, says McDermott. "Unfortunately, drinking too much creates the same symptoms as drinking too little," he explains. Use the above equation to ensure you're not over- or under-doing it.