Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integer converts to 2 octet integer?

 
M. Azri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a requirement that goes something like this:

- Integer should be transmitted in 1, 2, or 4 octet. Integers lager than 1 octet is transmitted with the least significant octet first.

- Example, integer 123 (007b hexadecimal) will be transmitted in a 2 octet integer as follows:

(Binary) 0111 1011 0000 0000
(Hex) 7 B 0 0

So how do I actually convert 123 to 2 octet integer in Java?

Put it in an array byte[4]? An example would be much appreciated.

Thanks.
 
Gregory Robinson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This this link

querycat

Regards,
Gregory
Olemera
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic