2

Does using a Byte(8 bit integer), which still is typecasted and added to an integer(32 or 64 bit integer, depending on machine architecture/registers), reflect good programming practice.

Given that it is typecasted to int anyway, Would it be recommended to use an int itself instead? (At a micro level : using byte saves memory space but adds CPU overhead - for typecasting. Using int saves that CPU overhead while saving that memory.) Which one would you recommend.

Note : The Data Type Byte just suffices for the data field in question, by design(Unsigned value that never exceeds 255). I would like my solution to be optimized by design.

DL Narasimhan
  • 731
  • 9
  • 25
  • 1
    Or see [Any reason to use byte/short etc.. in C#?](http://stackoverflow.com/questions/906198/), or [Byte vs Short vs Int (Along With The Unsigned Variation) In C#?](http://stackoverflow.com/questions/5064712/), or [How is memory allocated in int array](http://stackoverflow.com/questions/19049336/), or [Does using small datatypes (for example short instead of int) reduce memory usage?](http://stackoverflow.com/questions/6198240/) or [suit yourself](https://www.google.com/search?q=C%23%20memory%20byte%20int%20site%3Astackoverflow.com). – CodeCaster Jun 25 '14 at 11:20

0 Answers0