Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparison QB64 compiled with gcc optimizations and without
#56
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
Reply


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



Users browsing this thread: 44 Guest(s)