Fitbit research scientist Jonathan Charlesworth said these guidelines are based on how much time people spend in bed as opposed to how much time people actually sleep. However, he said even Fitbit's numbers are just averages, and the numbers can vary per person, especially based on factors like age and gender.

Using sleep data from its wearable devices, Fitbit researchers compared them to users' scores on Think Fast, an app Fitbit offers on its smartwatches. They found that people who slept an average of 5 hours and 50 minutes to 6 hours and 30 minutes per night performed better on the test than people who slept more or less. These amounts are shorter than what doctors typically advise. Public health officials and physicians have long recommended adults sleep for at least seven hours, if not more, each night. They've become increasingly vocal about this as people work longer hours and spend more time in front of screens before bed.

You might not need as much sleep as you think, but you might need better sleep.

"There are a couple things to take home here: The amount of sleep you're getting is significantly lower than the time you spend in bed, and the optimal time is probably largely lower than what you think," Charlesworth said.

Still, the ideal number Fitbit found reflects time people spent actually sleeping. Those same people likely spent about seven hours in bed when adding in the time they were awake before falling asleep and in the middle of the night.

Researchers also found how much sleep you need depends on your gender. Women need about 30 minutes more than men, according to their data.

And it's not just about quantity. It's also about quality, especially for older people.

Researchers found in both men and women over age 40, reducing the amount of time spent awake at night increases cognitive performance by 10 percent. For people ages 20 to 40, there was no correlation between the amount of deep sleep, interruption during the night and cognitive performance, Charlesworth said.

"This suggests that if people can maintain a high sleep quality as they get older, we may be able to slow decline by a significant amount," Charlesworth said.

Fitbit devices identify sleep based on users' heart rate and motion. It's not a perfect measure since the wearable does not track brain waves, but it's been shown to accurately determine sleep stages.

The company collected data from more than 3 billion nights of logged sleep for this research. It plans to use the findings to send users personalized insights so they can improve their sleep, Charlesworth said.

That may include sending users notifications saying they didn't sleep well last night along with suggestions like removing their phone from their bedroom, he said.