Server Help

Bot Questions - types

Anonymous - Thu Feb 19, 2004 6:34 pm
Post subject: types
why did catid make so many different numeric types of data structures ie:Uint32.. etc ? why wouldnt a simple int work... thanx in advance
ExplodyThingy - Thu Feb 19, 2004 6:49 pm
Post subject:
Because, its smaller and more effective.
Cyan~Fire - Thu Feb 19, 2004 6:50 pm
Post subject:
Well, it's a major pain when you want to type 'unsigned blah' over and over again. And the reason it can't just be signed is because numbers can go over the halfway point of an int in SS, causing them to be negative. Basically, it's just a lot cleaner (and more secure) to keep unsigned numbers unsigned.
Helicon - Thu Feb 19, 2004 7:46 pm
Post subject:
Uint32, etc are usually macro-defined shortcuts for types in (usually) c-likelanguages, among others.
The problem with packaged ints is that they may use much more space than is necessary.
For instance, a built-in integer for any given language may be 32 bits, which then supports (correct me if im wrong) positive and negative integers with absolute value of 512.
However, what if i need values up to 1000? setting a uint32 (unsigned int 32 bits) gets me ONLY positive number support up to 1024.

Code: Show/Hide

int x = 1020; //error
uint32 y = 1020; //ok


also, shorthand primitives may be used to save space, as in using only a sint16 (signed integer 16 bits) rather than just an int (which 16 unnecessary bits);
Code: Show/Hide

for(int x=0;x<=200;x++){
int y = x; //memory waste!
sint z = d; //thats a little better
}


once again, i didn't check my math here (i shouldknow it by heart), so please take the literals only as stand-in placeholders
Dr Brain - Thu Feb 19, 2004 8:13 pm
Post subject:
32 bits gives a helluva lot more room than +-512.
Helicon - Thu Feb 19, 2004 9:25 pm
Post subject:
msdn wrote:
The Int32 value type represents signed integers with values ranging from negative 2,147,483,648 through positive 2,147,483,647.

Cyan~Fire - Thu Feb 19, 2004 10:24 pm
Post subject:
Except you use UInt which is... double that.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group