which is faster using bytes or ints

BlitzMax Forums/BlitzMax Programming/which is faster using bytes or ints

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Ints, Ints, Ints!


If you store your data as bytes but you read a whole Int at a type and then use masking etc to isolate each part


This can be true - and it can be more convenient, eg: in the case of 'red shl 16 | green shl 8 | blue', but don't then go and do this:

Local red:Byte=color shr 16
Local green:Byte=color shr 8 & 255
Local blue:Byte=color & 255

...the vars won't be 'packed' in any way, and as soon as you need to do anything useful with them they'll have to be converted back to 32 bits (because we're using 32 bit CPUs!).

Instead, stick with Ints...

Local red:Int=color shr 16
Local green:Int=color shr 8 & 255
Local blue:Int=color & 255

So don't think of red, green and blue as 'bytes' packed into an Int, just think of them as compressed ints.