-1

Say I have an integer number: 11728322732 how can i convert it to a string according to its byte representation, i.e 11100011000000001100000111110001 (32 bits \ 4 bytes \ integer)

Thanks

0

1 Answer 1

0

Here it is:

Long.toBinaryString(11728322732L);

Actually, 11728322732 is not an Integer but a Long (because it is greater than Integer.MAX_VALUE). So if you really want to convert this long to a 32-bits int (can't figure why actually), you could do:

Integer.toBinaryString((int)11728322732L);
Sign up to request clarification or add additional context in comments.

5 Comments

Good answer, but that number is bigger than Integer.MAX_VALUE ;)
@aliteralmind good one. Fixed it!
I use integers so Integer.toBinaryString(...) works just fine, thanks
Does anyone knows how can I convert a binary representation back to int ? for instance 11000000 to 192 ?
Integer.parseInt("11000000", 2); (that means "convert it from base 2")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.