Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

The fastest way to convert integer into binary byte array and vice versa

807606Mar 5 2007 — edited Mar 5 2007
Hi,

I know there are quite a few similar questions which have been posted here, and I know how to do this in a naive way based on the conversion between decimal and binary numbers, but I wonder what is the most optimal (mainly in terms of speed) way to do it.

To reiterate, say if I have an integer i, and I want to convert i into a byte array full of 0s and 1s, and vice versa.

Many thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 2 2007
Added on Mar 5 2007
14 comments
1,566 views