Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

byte datatype!  RSS feed

 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
could you please explain me when do we need byte datatype? similarly, could you also please tell me the situation the Shift operators (>>, >>>) are required?
thanks.
[ edited to diable smilies -ds ]
[ June 15, 2003: Message edited by: Dirk Schreckmann ]
 
Edwin Keeton
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The byte datatype is needed to store integer values within range in the least amount of memory. A JVM might be implemented on processors with smaller than 32-bit registers, and memory resources are not always abundant.
Not many people "have" to use bit-shifting in "normal" coding. It's been a while, but IIRC some compression algorithms use bit-shifting. I'm sure there are other situations too.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some mathematical operations can be done more quickly with the bit shifting operators.
The byte datatype is also useful when the data to be used/manipulated is available in byte-sized pieces (such as with some I/O operations).
[ June 22, 2003: Message edited by: Dirk Schreckmann ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!