QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: johnno56 on September 13, 2021, 05:27:33 pm
-
I enjoy using Basic to calculate basic (no pun intended) Astronomical stuff. For the past several decade I have been using a book, "Practical Astronomy with your calculator". Time for an upgrade. Write a simple program to do it for me... Right?
My very first problem... Divide 2000 by 19. How simple could you get.... My handheld calculator states: 105.2631579. My computer's calculator states: 105.263157895 and RCBasic states: 105.263158. However, QB64 states: 105.2631607.
I know the difference is quite small, but when it comes to Astronomy, precision is a must.
Can someone check this simple equation on both computer and calculator... Just in case I may be doing something wrong? An explanation for the difference and a possible solution would be appreciated.
J
-
My string-math app gives me:
105.2631578947368421052631578947368421052631578947368421052631578947368
105.2631578947368 via Windows 10 calculator.
Pete
-
n## = 2000## / 19##
PRINT "105.2631578947368421052631578947368421052631578947368421052631578947368"
Comparing to Pete's string math figure, I get 17 digits of matching precision. It isn't until the 18th digit that the numbers vary by a minute amount.
(105.263157894736842105 is the value I'm getting, if you're curious.)
-
So I looked up this inline big numbers calculator, and fed in 100 digits after the decimal place. My string math is shown on top, and the online results directly below. Nice to know my 68th digit after the decimal is correctly rounded, but I can't remember if that's a coincidence or if I programed it to toss the last digit and round.
105.2631578947368421052631578947368421052631578947368421052631578947368
105.2631578947368421052631578947368421052631578947368421052631578947368421052631578947368421052631578947
Anyway, if you want to check it out to up to 9,999 decimal places, go here...
https://www.calculator.net/big-number-calculator.html
However, see the pattern? This decimal infinitely repeats as .263157894736842105
Pete
-
@johnno56
Try QB64 highest precision for default variable type
[ This attachment cannot be displayed inline in 'Print Page' view ]
-
@bplus Remember to use Print Using -- you can specify to display a higher degree of printed results than with Print alone. (See my post above and compare to yours. I have several extra digits of precision displayed.)
-
Thanks guys. Calculating the phase of the moon or the next eclipse or the approximate position of the planets could get by with six to nine decimal places.... Much appreciated.
J
-
Just make sure you mark my post as "The Best Answer" or you'll get my full moon in your phase!
Pete :D
-
hey Pete, here's challenge for you, find the first 50 digits of 2^(2^(2^(2^(2^2)))) https://community.wolfram.com/groups/-/m/t/2359839
you can calculate the answer easily enough using the pari/gp program http://pari.math.u-bordeaux.fr/
-
6.031226062630295×10^19727.78040560677
I'll settle for 11!
Pete
-
not quite right
-
2^(2^(2^(2^(2^2)))) is equivalent to 2^(2^65536)
-
it's more like 2.12003872880821198488x10^(10^19727.780405607)
-
it's more like 2.12003872880821198488x10^(10^19727.780405607)
Might as well be the SQRT(-1) on my farm. As far as I can tell, they’re both imaginary numbers with no real bearing on my life! :P
-
Well find a round whoe and have her dig those square roots up!
Pete
I tried measuring an atom once, but I couldn't get the the damn thing to hold still. It cost me my job at the nuclear accelerator plant. You know like they say, measure twice, split once.