Answered by:
Help need to compute the Gravitational force between Sun and Earth
Question

Hi,
I am trying to create a little basic program in small basic, that will compute
The Gravitational force between Sun and Earth.For this i need Newton Gravitational law:F= G x ( m1 x m2 ) / r^2
where F = gravitational force
where G = is the gravitational constant, approximately 6.674×10^−11
where m1 = mass of the Sun in kg ( see Sun in wikipedia)
where m2 = mass of the Earth in kg
r = distance between Sun an Earth in meters EXPONENT 2so in small basic i have:Earth_Mass = (math.Power(10,24))*5.9736Sun_Mass = (math.Power(10,30))*1.9891Distance = 149,597,870,700G = (math.Power(10,11))*6.67384
this is the final formula in small basic:F = G * (Sun_Mass*Earth_Mass) / math.Power(distance,2)
and small basic will returned a kind of overflow error, and the my program stop.
the numbers involved here are to big, i think...what can I do ? any idea :)
the answer must be : 3,543 x 10 exponent 22 Newtons.
Answers

Simplified version of NaochanON's solution.
Earth_Mass[1]=5.9736 Earth_MassPow=24 'math.Power(10,24)*5.9736 ' (kilograms) Sun_Mass[1]=1.9891 Sun_MassPow=30 ' math.Power(10,30)*1.9891 ' (kilograms) 'Distance Sun to Earth: 149,597,870,700 meters distance[1]=1.49597870700 distancePow=11 'The gravitational constant, approximately 6.674×10^−11 and denoted by the letter G G[1]=6.67384 GPow=11 'math.Power(10,11)*6.67384 'GRAVITATIONAL FORMULA BY NEWTON 'F= G x ( m1 x m2 ) / r^2 Ff= G[1]*Earth_Mass[1]*Sun_Mass[1]/(math.power(distance[1],2)) ForcePow = GPow+Earth_MassPow+Sun_MassPow(2*distancePow) F= Ff*math.Power(10,ForcePow) ' < Small basic can show this value TextWindow.WriteLine(F) cP= Text.GetIndexOf(Ff,".") Ff=Ff/math.Power(10,cp2) ForcePow= ForcePow+(Cp2) TextWindow.WriteLine("F= "+Ff+"*10^"+ForcePow)
It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11
 Proposed as answer by litdevModerator Thursday, February 11, 2016 8:15 PM
 Marked as answer by litdevModerator Wednesday, February 24, 2016 1:35 PM
All replies

See the answer in the other topic where you asked this:
https://social.msdn.microsoft.com/Forums/enUS/defa0b6dcae245b583f305ee7ae893de/whatiswrongwiththiscode?forum=smallbasic#75a6a8855912485fb65b0a7c41f0c4f7
Jan [ WhTurner ] The Netherlands

Simplified version of NaochanON's solution.
Earth_Mass[1]=5.9736 Earth_MassPow=24 'math.Power(10,24)*5.9736 ' (kilograms) Sun_Mass[1]=1.9891 Sun_MassPow=30 ' math.Power(10,30)*1.9891 ' (kilograms) 'Distance Sun to Earth: 149,597,870,700 meters distance[1]=1.49597870700 distancePow=11 'The gravitational constant, approximately 6.674×10^−11 and denoted by the letter G G[1]=6.67384 GPow=11 'math.Power(10,11)*6.67384 'GRAVITATIONAL FORMULA BY NEWTON 'F= G x ( m1 x m2 ) / r^2 Ff= G[1]*Earth_Mass[1]*Sun_Mass[1]/(math.power(distance[1],2)) ForcePow = GPow+Earth_MassPow+Sun_MassPow(2*distancePow) F= Ff*math.Power(10,ForcePow) ' < Small basic can show this value TextWindow.WriteLine(F) cP= Text.GetIndexOf(Ff,".") Ff=Ff/math.Power(10,cp2) ForcePow= ForcePow+(Cp2) TextWindow.WriteLine("F= "+Ff+"*10^"+ForcePow)
It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11
 Proposed as answer by litdevModerator Thursday, February 11, 2016 8:15 PM
 Marked as answer by litdevModerator Wednesday, February 24, 2016 1:35 PM
