You are correct, but there are two issues here -
1. If I have to print out the results and I have no idea how large or small the results will be, QB64 adds garbage at the end of the number AND
2. This is a simple standard deviation. We use this with numbers that are more than 25 significant digits, or have more than 25 decimal places (or both) and the results are just not there.
But QB64 has more problems than many interpreters that run on mobile devices, whose hardware isn't as robust as our desktops.
Here is part of a program I wrote many years ago after I had to appear before an inquiry board to explain why my results, or the system's results, were inaccurate. Here I just include the most simplistic tests of processor/language number accuracy tests, that use the most basic physics figures known to even layman. I also included a comparison to a run I did in TechBASIC on my iPad.
You'll see that the iPad, even though both contain garbage in their numbers that do affect the results of any calculation in it, gets closer to the right answer than QB64 does. In fact, I have no clue why !E+308 produces garbage results (not even close to the right result) and the iPad gets it 100% correct!
Note, the program is exactly the same on the iPad. The iPad's TechBASIC uses DOUBLE FLOAT for all the variables. In QB64, I use both DOUBLE and _FLOAT and get the same results. (TechBASIC is written in C, so there is no reason why QB64 can't get this simple math correct!)
Here is the program followed by screen shots of both a QB64 run (in 64bit) on a Linux, and the TechBASIC run. The code is 100 percent the same.
This is a problem that must be fixed on the compiler side.
X = 2 ^ 52 - 1
Z = 2 ^ 53 - 1
W = X + X
Y = 2 * 10 ^ 30
Y1 = 2D * 10D ^ 30D
B = 2D0 * 10 ^ 30D
C = 2D0 * 10D ^ 30D
D
= 2D0
* EXP(30 * ln
(10D0
))E
= 2D0
* EXP(30D
* ln
(10D0
))
A = 1E+308
A$ = "1E+308"
LY = ((186000 * 60 ^ 2) * 24) * 365.25
PRINT "The maximum absolute value 2^52 = ";:
PRINT USING "#,###,###,###,###,###"; X
PRINT USING "Add #,###,###,###,###,### to itself = #,###,###,###,###,###"; X
, W
PRINT "The maximum absolute value 2^53 = ";:
PRINT USING "#,###,###,###,###,###"; Z
PRINT "As an exponent, the Sun's Mass. = "; Y$
PRINT "The mass of the Sun 2*10^30 ";:
PRINT USING " = #.#####################^"; Y
PRINT "The mass of the Sun 2d*10d^30d ";:
PRINT USING " = #.#####################^"; Y1
PRINT USING "The answer of B using all _FLOAT = #.#####################^"; B
PRINT USING "The answer of C using all _FLOAT = #.#####################^"; C
PRINT USING "The answer of D using all _FLOAT = #.######################"; D
PRINT USING "The answer of E using all _FLOAT = #.######################"; E
PRINT USING "Light Year = ###,###,###,###,###,### miles"; LY
Here is the QB64 Run:
[ You are not allowed to view this attachment ]
Here is the TechBASIC run on the iPad:
[ You are not allowed to view this attachment ]
after the second loop SUM = 964 so SQR(SUM / 9) is going to vary depending on the precision, it's not going to be exactly 10.34945 except perhaps for single
bplus or STxAxTIC could probably write a pre-parser that would convert a basic program's math expressions into a program that would call string math functions