Search code examples
javaintegerbytedataoutputstream

How can I write 7 byte Integer value to DataOutputStream, which contains 15 digits?


I have to write 7 byte Integer value to DataOutputStream, this Integer contains 15 digits. How can I do that?


Solution

  • 7 bytes = 56 bits
    that means you can represent numbers up to 2^56 which is more than necessary for 15 digit long numbers.

    just convert the number to binary and store it in those 7 bytes that you're sending.