If billions of people devoted their lives solely to counting, they could actually count the numbers of stars and sand grains, because neither figure is infinite.

The universe and its starry contents come to an end somewhere out there beyond our wildest imaginings. And although it may feel like the number of grains of sand on a beach is infinite, those too are limited. Using eyeball estimates, mathematical calculations, physical laws, and sophisticated photography, Dr. Neil D. Tyson, an astrophysicist at Princeton University, has come up with the numbers.

Here’s how he did it, and what they are.

Ever since Newton wrote the laws of gravity, astronomers have used the formulas to calculate the mass of planets, stars, and even whole galaxies based on how fast these bodies travel in orbit.

Astronomers know, for example, that the sun’s mass is 2 x 1030 kilograms and that our whole galaxy, the Milky Way, has a mass of about 100 billion times that of the sun. Most of this mass is composed of stars similar to the sun, so we can safely say that our galaxy has about 100 billion stars.

If we take our galaxy as average, then with the number of stars per galaxy in hand, Tyson now needs to know the number of galaxies in the whole universe.

A sophisticated photographic technique that uses a very sensitive digital detector, called a charge-coupled device, enables astronomers to take a very deep photo of the sky. Correcting for the fact that some galaxies are too dim to see, and estimating the number of galaxies astronomers would find if they shot photographs of every piece of the sky, astronomers have determined that there are about 10 billion existing galaxies.

Tyson multiplies the 10 billion galaxies by the average of 100 billion stars in each galaxy to arrive at an estimate of the total number of stars in the sky: one sextillion, or a one followed by twenty-one zeroes.

Now on to sand. Tyson took a day trip to New York’s Jones Beach and counted the number of grains of sand along a length

of one centimeter. He counted about twenty-five.

Allowing for some beaches to have much finer grained sand, as on the American Gulf Coast, and others to have big grains, Tyson estimated that there are about fifteen thousand grains of sand in a volume of one cubic centimeter on any given beach. He then judged that the average beach is about five kilometers long, one kilometer wide (from the edge to the high-tide line) and 0.015 kilometer (fifteen meters) deep.

The volume of the average beach is therefore 0.075 cubic kilometers, or 75 trillion cubic centimeters. With 75 trillion cubic centimeters of sand on a beach that size, and fifteen thousand grains of sand in each cubic centimeter, the total number of sand grains on a beach would be about one quintillion, or a one followed by eighteen zeroes.

A sextillion is a thousand times bigger than a quintillion, so there are quite a lot more stars in the sky than grains of sand on a beach. Now let’s say there are a thousand big beaches on planet earth; that would mean a sextillion grains of sand, or about the same number as all the stars in the universe. But then keep going. You could also add the sand grains under the ocean, and the sand on the Sahara Desert.

“And that’s the ball game,” says Tyson. Sand grains win. By how much? No one’s counted yet.