Posts: 4
Threads: 1
Joined: Sep 2023
Reputation:
0
Hello all. I have a problem that has been plaguing me in my QB64 adventure. If I have a variable, and I increment it, by just the number 1 in a loop, when it gets to 1.677722E+07 (24 bits) it just stops and increments no more. Doesn't matter if I use LONG or _INTEGER64 data types, or don't declare a type at all.
Sounds like it has to be a bug, and a weird one. Why 24 bits? Anyone else see this?
Posts: 1,587
Threads: 59
Joined: Jul 2022
Reputation:
52
Welcome to the forums.
You are expecting help but do not post source code. So we have to guess what you are trying to do.
Are you using `PRING USING` to output the variable's value? This is one of the biggest offenders.
If you are incrementing by one, make sure it is `1` as integer, and it's not floating point. Because QB64 sometimes needs the programmer's help by type-casting like must be done regularly in C/C++.
Otherwise 24 bits should easily fit into a `LONG` (32-bit) variable.
Posts: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
1.677722E+07 is floating point, and you're at max single digit precision.
16777220 <-- this is what the value above translates to.
16777221 <-- add one
1.677722E+07 <-- and the above still rounds to the same value.
You're doing floating point math, not integer addition.
Posts: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
If you're dimming your variable as long or integer64, be certain it's SHARED if you use it in SUB/FUNCTIONs, or else specify the type in your parameters.
SUB foo (var AS LONG)