User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

C++ Big Math Data Types

Fri Apr 05, 2013 4:12 pm

Say I have a value of several billion which I need to multiply by a tiny, tiny number then divide the result by another very large number (it's all to do with gravity) then do some adding up etc., what are the best data types to use ?
And is there a library for doing this kind of calculation without the loss in precision of floating point arithmetic ?

Any help appreciated.
Dave.
Apple say... Monkey do !!

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: C++ Big Math Data Types

Fri Apr 05, 2013 4:39 pm

Are you sure a 'long double' is not enough?

Maybe this http://gmplib.org/
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: C++ Big Math Data Types

Fri Apr 05, 2013 5:18 pm

Oh yes indeedy -rst-, long doubles are plenty!!

If only I'd defined the gravitational constant as 6.67384e-11 instead of 6.67384e11, me stupid.

I do believe NASA crashed an otherwise perfectly good rocket by omitting a minus sign :)

Cheers.
Dave.
Apple say... Monkey do !!

Return to “C/C++”