Long double is enought big to store a distance like the Sun-Pluto one whit millimeter precision?

109 views Asked by At

I am programming a physic simulation, and every element of the system simulated is described whit three dimension (x, y, z) stored in three long double. Well, my precision would be pretty precise, and I'd like to simulate enough vast systems, like the solar system. Considering the Sun in the center, how much can I go further to keep precision higher or equal to millimeter, and which measurement unit should I use?

P.S.:
I know that the solar system is much larger that the distance Sun-Pluto, but that distance is the minimum size that I'd like to consider valid in my simulation

1

There are 1 answers

0
chux - Reinstate Monica On BEST ANSWER

The "Pluto/Sun mean distance" is 5.9*1012 meters or 5.9*1015 mm.

Typical double has 253 or about 9*1015 decimal precision and so can represent the Sun/Pluto distance exactly - to the millimeter.

Start with double and focus on code's various calculations that may compromise precision. If necessary use long double, yet I suspect double will work for you.