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

Bits and bytes through Java...

Options
  • 24-01-2003 10:37am
    #1
    Posts: 0


    Hey all,

    Could anyone please tell me how to calculate low and high bytes of a number in Java?

    For example, if I gave a parameter of say 256 (each register is 16 bits), the high byte would be

    00000001

    and the low byte

    00000000

    Using the bit shift operators, how would I calculate these values?
    I've been trying this for the last few days and it's driving me up the wall.

    Thanks for any help :)


Comments

  • Registered Users Posts: 1,931 ✭✭✭Zab


    The low byte would be

    i & 0xff

    And the high byte would be

    ( i >> 8 ) & 0xff


    Zab.


  • Posts: 0 [Deleted User]


    That's great, thanks for the help


Advertisement