Page 1 of 1

Quad support with For/Next

Posted: Thu Oct 06, 2016 9:17 pm
by Keya
Can't do, but would be nice:

Code: Select all

For i.q = 1 To 5    ;for example if i is a file offset and we want to read more than 4GB
 Debug Str(i)
Next
Can do:

Code: Select all

i.q=0
Repeat
 i+1
 Debug Str(i)
Until i = 5

i.q=0
While i < 5
 i+1
 Debug Str(i)
Wend

Re: Quad support with For/Next

Posted: Fri Oct 07, 2016 12:37 am
by normeus
I get no error output with the following code on win 7 5.42LTS 64x. ( I wish I would get an error)

I guess it is because it is a runtime error but since the numeric limit is built into the statement I would like a cryptic <Buffer overflow error> from the debugger.
I know the "TO" becomes -122..etc.. and that's why the loop does not run
but the compiler knows I am using a FOR NEXT and it should warn me about using larger variable types.

Code: Select all

 Define i.q
  Define upper.q=  9230000000000000000 ; change the 3 to a 2 and it will run. 
                   ;9223372036854775807 max 64bit int
  Define lower.q = 8900000000000000001 
  
  ;step
  #stec=            2150000000 ; change the 5 to 4 from #stec to get right output
                   ;2147483648 max 32bit int
  
  For i = lower To upper Step #stec   
      Debug i
  Next
Norm.

Re: Quad support with For/Next

Posted: Fri Oct 07, 2016 2:14 am
by Keya
sorry I should've clarified i meant support for x86! :) It's not a problem in x64 because Integer vars which For/Next uses are already 64bit, but Integer vars on x86 are 32bit and they don't let you use Quad

Re: Quad support with For/Next

Posted: Fri Oct 07, 2016 6:12 am
by wilbert
I didn't know this isn't possible.
It might be nice if it would be supported but when it comes to performance, it's better to do things differently.
I don't know if the difference is big but a quad based loop on x86 would be slower since the value to work with doesn't fit in a register.