Hi guys, just a quick question:
I'm using a lot of const/var byte and I just read somewhere that int performs slightly better because it is already aligned for native CPU instructions. And byte should only be used to store values between -128 and 127.
Is that the case for ZGameEditor?
byte VS int in ZGE
Moderator: Moderators
Re: byte VS int in ZGE
Hi Ats,
K
Completely depends on the circumstances & instructions involved, but in general you shouldn't be able to notice any difference.
Bytes in ZGE are unsigned, so they range from 0 to 255. Also, keep in mind that bytes aren't really bytes when you use them as local variables ( at the moment ).
Code: Select all
byte foo = 999; // Outside 0-255 range
trace(intToStr(foo)); // Still outputs 999
Re: byte VS int in ZGE
Use int everywhere is general good advice. Only thing to consider if you are creating huge arrays, then using byte if possible will save memory.
Indeed like Kjell points out byte range is not enforced on local variables (only when stored to global variable or array is it truncated to 0..255 range).
Indeed like Kjell points out byte range is not enforced on local variables (only when stored to global variable or array is it truncated to 0..255 range).