Array maximum dimensions and size

Started by SpellSword, July 08, 2007, 02:54:00 AM

Previous topic - Next topic

SpellSword

I have a question, (Noob-ish as it may be...)

And here it is:
What is the maximum number of dimensions an array can possess in PB?
Is there a limit at all?

Example:
TheArray(10,10,10,10,10,10,10,10,10,10,10)

And, what is the maximum value for each of the array's dimensions? (If any)

Example:
TheArray(283834848484848848,59394589349583495895348,6586383638634683468,3486474376348763847684)
When I dream,
I carry a sword in one hand,
a gun in the other...

kevin

#1
 
QuoteIs there a limit at all?

Yes there's a limit .. 2^30

Your computer will run out of memory LONG before you ever get anywhere near that though :)


SpellSword

Wow! Barring memory limitations, an array of this size is possible!
HugeArray(1073741824,1073741824,1073741824,1073741824,1073741824,1073741824,1073741824,1073741824,1073741824)
I'm not planning to use any arrays with a coordinate value 'that' high but it's interesting to know.

Thanks for the info.
When I dream,
I carry a sword in one hand,
a gun in the other...

kevin

#3
   Just for further clarification,  the total numeric range of a integer/float array is 2^30.  So in a single dimension array, the indexes could theoretically range from  0 to 2^30.     The more dimensions you have, will lower index range in each dimension.      

  Since a 2D array is easier to visualize,   imagine a square grid.   X ranges from 0 -> 1073741824,  Y ranges from 0->1073741824      

  So the area of the array would be  X * Y  (1073741824*1073741824)  = 1,152,921,504,606,846,976 cells

  Which obviously exceeds the arrays maxim area of 2^30 =1073741824.    So for the array to be legal size (in a 32bit computer) it's total area must be bellow 2^30.  

 
Recommended Reading:

    - Beginners Guide To Basic Game Programming (Index)