BIG number help, possible array bug.

Blitz3D Forums/Blitz3D Programming/BIG number help, possible array bug.

Vertigo(Posted 2007) [#1]
OK guys, try to run this with debug on... Notice how the first part of the for/next completes and the second part fails?

What I am trying to do is create a placeholder array for DirectPlay ID's that I can use as pointers for types to get a quick lookup. I need to allocate a 32bit integers worth of data as an array (-2147483648 To 2147483647). Not that even 2% of these numbers will ever be used... but they are unique and it just works that way. Anyways... Is there a way to use large numbers in blitz, and is there a bug with the below code?

Thanks,
Scott


;Should be able to hold double this correct?
 Const IDS% = $7FFFFFFF

Dim User_ID%(IDS%)

; Bliz uses 32 Signed integers right?
; Value of -2147483648 To 2147483647

For D = 1 To 5;Why do numbers 2 through 5 complete.

	User_ID%(D) = D

Next

For D = 1 To 6;Yet THIS fails.. what the heck?
	User_ID%(D) = D
Next

;For D = 1 To 2147483647   ; Not even going to try.
;	User_ID%(D) = D
;Next




H&K(Posted 2007) [#2]
Right.

How much memory do you think 2147483647int would be?
Is that 8Gig? Or is my maths wrong?


Vertigo(Posted 2007) [#3]
Well if All values are NULL its not taking up any memory correct? My biggest question is why will it complete and execute allowing you to fill 5 integer spots, yet fail on the 6th? Im well aware this wont work.. I was just curious what the heck causes the above issue.


Floyd(Posted 2007) [#4]
I guess the question is why does this do anything at all instead of crashing immediately.

Since the program runs it presumably tries to reserve memory for the array. An integer is four bytes so the array needs 4 * $7FFFFFFF bytes. This number overflows to become -4.

But the OS call probably uses unsigned values so this becomes (2^32) - 4 bytes. That is the entire 32-bit address space minus 4 bytes. So this isn't feasible either.