Sunday, 29 September 2013

Is Byte implemented as Int anyway?

Is Byte implemented as Int anyway?

I had a java game book recommend implementing all data as Int when
possible, that that type runs the fastest. It said the Byte, Char, and
Boolean are implemented as Int anyway, so you don't save space and the
casting you end up having to do in the code because of the Byte data will
slow it down. For instance, a cast is needed for
a = (byte)(b+c);
since the addition result is an Int, even when a,b, and c are all declared
as Bytes.
I currently have a huge 2D array declared as Byte for my game, to save
space and for bitwise operations. Is it actually saving space? I've also
seen bitwise operations done on Ints in examples, do bitwise operations
work as expected on Ints?

No comments:

Post a Comment