Active Forums => QB64 Discussion => Topic started by: RhoSigma on February 19, 2019, 07:11:51 pm
Title: FOR/NEXT or big number bug?
Post by: RhoSigma on February 19, 2019, 07:11:51 pm
The following example quickly shows the issue, although the loop variable and literal numbers are explicitly marked as _UNSIGNED _INTEGER64 by using the respective type suffix (~&&), the first loop is skipped completely as it obviously want run from 0 TO -1 instead of 0 TO 18446744073709551615. The second loop does exclude the usual sign bit (&H7F... instead of &HFF...) and is therfor correctly entered.
This happens only with _UNSIGNED _INTEGER64, while it works correctly for (_UNSIGNED) LONG, INTEGER and _BYTE, where both loops are entered. By this fact I think it's rather a FOR/NEXT issue than a general _UNSIGNED numbers issue.
Since you're trying to do a FOR loop from 0 to &HFFFFFFFFFFFFFFFF~&&, you're actually counting to &HFFFFFFFFFFFFFFFF~&& + 1 -- which is going to overflow and not work as you're intending.
Title: Re: FOR/NEXT or big number bug?
Post by: SMcNeill on February 21, 2019, 06:34:56 am
Actually, scratch that...
If you look inside maindata.txt, at our translated code, it's obvious what the issue is, in this case:
The variables are declared as int64 values and not unsigned int64s. The limit is going to be INT64 bounds, unless somebody wants to go in and track down the relevant lines in the source to properly translate the values for us when uint64s are needed instead.