Tom Hanks says he's been diagnosed with type 2 diabetes after a decades-long battle with high blood sugar.

"I went to the doctor and he said, 'You know those high blood sugar numbers you've been dealing with since you were 36, well you've graduated. You've got type 2 diabetes, young man,'" the 57-year-old "Captain Phillips" star told "Late Show" host David Letterman.

Hanks, who appeared slim and fit on the talk show, said he was advised to shed some pounds to control the chronic condition.

"My doctor said, 'Look, if you can weigh as much as you weighed in high school, you will essentially be completely healthy and will not have type 2 diabetes.' And then I said to her, 'Well then I'm going to have type 2 diabetes because there is no way I can weigh as much as I did in high school."

"I weighed 96 pounds in high school," Hanks added, calling his teenage self "a very skinny boy."

Letterman, who underwent heart bypass surgery in 2000, admitted that he, too, suffers from "the high blood sugar" and has had to go on a special diet.

Tom Hanks says he has type 2 diabetes. (Image credit: Craig Barritt/Getty Images)

Type 2 diabetes is a chronic condition that affects the body's ability to metabolize sugar. Unlike type 1 diabetes, which attacks the insulin-producing cells of the pancreas, type 2 diabetes occurs when the body produces insufficient amounts of the hormone or becomes resistant to its effects.

"Type 1 diabetes is very bad. Type 2 diabetes is controllable," Hanks told Nerdist Thursday. "You've just got to lose weight and exercise a lot and change everything you eat and never ever ever ever ever have any fun whatsoever."

Weight and inactivity are major risk factors for type 2 diabetes, according to the U.S. Centers for Disease Control and Prevention. Hanks has gained and lost weight for his many movie roles, appearing heavier in "Captain Phillips" than in "Cast Away" and "Philadelphia."

"Sometimes I'm in pretty good shape, other times I'm not," the actor admits in his Twitter biography. "Hey, you gotta live, you know?"

Now faced with type 2 diabetes, Hanks said "it turns out, I do want to live."

"And it means I have to stay skinnier," he told Nerdist.