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

BigEndian and LittleEndian  RSS feed

 
Patrick Mirov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm hoping that this is being posted in the correct section... If not, I am sorry I'm still fairly new to the language.

Could someone give me a brief explanation on how endianess works in Java? Better to ask, in what senario would Endianess come into play and how would/should it be used? I only know what I've read on Wikipedia and that really doesn't help me much if I don't have some comprehensive examples :P .

-Thanks
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The way values are stored in Java is not something you generally need to worry about - is there a specific reason why you need to know this?
To find out information such as this you need to read the JVM Specification. If you read chapter 4 in the JVM spec you will see it states multibyte items are stored in BigEndian order.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would generally have to think about endianness if you have a network connection to some other machine, and are sending/receiving raw bytes. Such a process would generally use the byte order that is the default on the system it runs on - which may or may not be the same byte order of the machine where your code runs.

As Tony said, Java generally uses "network byte order" (BigEndian) so I think for communication between Java processes it's generally not a problem. But if one of the processes is not implemented in Java, you may have to do something about it (which may not be all that hard).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!