Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

getting an int from a byte[] ?

  • 23-02-2004 8:08pm
    #1
    Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭


    Is there an easy way to do this?

    I have a byte[] made up of 3 ints. How do I pull the ints from it?

    This is in Java btw.


Comments

  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Do you mean you have one integer made up of 24 bits, arranged in an array? In this case it's pretty simple, use BigInteger(byteArray).intValue()... as long as the integer isn't too big for an int type, in that case just leave it as a BigInteger. And you might want to make sure they're encoded as twos-complement first.

    Or do you mean you want to convert 3 bytes into individual ints? (just a cast, I'm sure you would've done that already yourself so I guess thats not it).

    Sorry, I'm not quite sure I understand what you're trying to do, you're not your normal verbose self! :p


Advertisement