Difference between double and long double in c++

1.5k views Asked by At

Can someone explain the differences between doubles and long doubles except for the difference in precision to me? I wrote a program to solve a gravitational n-body problem so i basically integrate second order differential equations and my program works fine using doubles. When i however replace all the doubles i use with long doubles all the calculations seem to produce nonsensical results. Can someone explain the reason for this?

On the contrary to what everyone seems to think i can't find the awnsers i'm looking for on the long double vs double thread.

1

There are 1 answers

1
Ya Wang On

Maybe refer to here: Why would you use float over double, or double over long double?

But simply a long is normally refers to something similar to an int.

I think you are looking for a long double... If you put only long it will mess you code up because its not a double or a float...

Here review data types: http://en.wikipedia.org/wiki/C_data_types