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

Bits and bytes through Java...

  • 24-01-2003 9: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, Registered Users 2 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