Real size of variables built-in types in memory (SOLVED)

Started by Monsieur OUXX, Wed 11/07/2007 12:55:31

Previous topic - Next topic

Monsieur OUXX

Hello, I'd like to ask CJ if script variables types int, char, float, etc  really have the size they're supposed to have (int = 32 bits, char = 1 byte, float = 32 bits), or if their size is homogenized by the engine, finally making them all 32 bits in memory.

(just like the Java virtual machine does : when you use a 'char', it gets converted to 'int' with bounds-checking, making it even slower than with a real int...)
 

Scorpiorus

#1
Let's wait for CJ to confirm, but from my own experience they have different sizes:

char - 8 bits
short - 16 bits
int - 32 bits

EDIT: And "float" takes 32 bits.

Pumaman

Yes, they are the actual size -- there wouldn't be any point otherwise, I'd may as well have just implemented an "int" type.

char jibble[1000]    takes up 1000 bytes
short jibble[1000]   takes up 2000 bytes
int jibble[1000]       takes up 4000 bytes

Monsieur OUXX

 

SMF spam blocked by CleanTalk