This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Converting binary to big endian Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Converting binary to big endian" Watch "Converting binary to big endian" New topic
Author

Converting binary to big endian

vignesh bala
Greenhorn

Joined: Aug 19, 2006
Posts: 28

Hi All,
I am having a doubt in network byte order. I am writing a socket client wherein I have to append the length of the message packet in four byte binary big endian format. But I have certain doubts in it. If I have a message whose length is 64 for instace, Then when I use "Integer.toBinaryString(64)" , I get 10000000, My doubts are,
1. Do I need to use 10000000 before the message as it is?
2. Do I need to use 00000000 00000000 00000000 10000000 [for 4 bytes].
Is it in big endian by default
3. How can I convert the value to 4 byte binary in big endian byte order

Can anybody give any clue regarding this?

Thanks in advance
Vignesh
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Converting binary to big endian
 
Similar Threads
Using ByteBuffer for Converting Byte Order from BigEndian to Little Endian.
octal/hex/binary/unicode ?
Installing Weblogic 7.0 SP5 on RHL WS 3
Doubt in negative numbers in binary format
Byte conversion to number