View Single Post
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 02-17-2017 , 12:33   Re: [ TUT ]Dynamic Array
Reply With Quote #24

Quote:
Originally Posted by edon1337 View Post
Sorry I understand things a little slowly. So if I want to use integers, I can make the cellsize 1, but what if I want to use huge values like 1000000, do I have to use cellsize 7?
No. If you set the size to 7, you can store arrays within 7 cell entries.
Code:
// Max cell entries = 7 new Array:array = ArrayCreate( 7 ) new max_array[] = { 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647 } ArrayPushArray( array, max_array )
The max value you can story in a array, or pawn variable (also known as Pawn cell) is the value of the max signed integer of 4 bytes (cellsize of 4 bytes), which is here 2.147.483.647
Code:
// Max cell entries = 1 new Array:array = ArrayCreate( 1 ) new max_interger = 2147483647 ArrayPushCell( array, max_interger )

The word cellsize is misleading, the cellsize should means how many bytes a single Pawn cell (an ordinary variable) can hold on. Here each Pawn cell has the `cellsize` of 4 bytes, which means it can hold signed integers until `2.147.483.647`.
If you still do not understand read:
  1. https://en.wikipedia.org/wiki/Integer_(computer_science)
  2. https://github.com/compuphase/pawn/raw/master/doc/Pawn_Language_Guide.pdf
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 02-17-2017 at 16:03.
addons_zz is offline