Comparison QB64 compiled with gcc optimizations and without
#57
(08-15-2022, 08:25 PM)Pete Wrote: Errors with binary math meaning errors occur when we use computer binary math to represent base 10 output. So it's not the language, it's the principle. For instance, try running the following...

Code: (Select All)
DIM j AS SINGLE
FOR i = 1 TO 10
    j = 1 / 10 + j
    PRINT i, j
NEXT
PRINT

FOR i = 1 TO 100
    j = .01 * i
    PRINT i, j
    SLEEP
NEXT
DIM k AS DOUBLE
CLS
FOR i = 1 TO 10
    k = 1 / 10 + k
    PRINT i, k
NEXT
PRINT

FOR i = 1 TO 100
    k = .01 * i
    PRINT i, k
    SLEEP
NEXT

You will see inaccuracies in both DIM models. So the computer counts in base 2, whatever the language. The only way around it is to make a math library for the language to access.

Pete

Sounds like a plan! (for someone with the time and interest! not me! lol)
Reply


Messages In This Thread
RE: Comparison QB64 compiled with Ofast and without - by madscijr - 08-15-2022, 10:23 PM



Users browsing this thread: 8 Guest(s)