The formula returns g1 with 8 decimal points: g1=9.79692356. Is there a way to truncate the returned value so that I have g1=9.7 ?
Thanks.
Code: Select all
REM g at the surface meters/second^2
g=9.8067
REM R=Earth radius in meters
R=6371000
REM h=altitude
h=0
REM Cavendish's value for density of Earth: 5448 kg/m^3
Delta=5448
PRINT "Using Cavendish's value for density of earth: 5448 kg/m^3"
FOR h=0 TO 4000 STEP 1000
g1=g*(1-(2*h/R))
PRINT "Altitude is: ";h; " meters"
PRINT "g1 is: ";g1
G_Delta=(3*g1)/(4*PI*(R+h)*Delta)
PRINT "G_Delta=";G_Delta
NEXT h
END