- How can I convert a byte to a long
How can I convert a byte to a long
You probably want to AND with 0xff to avoid sign extension:
long mylong = mybyte & 0xff;
Similarly when going to an int:
int myint = mybyte & 0xff;
Copyright © 2008-2021, dave. Code samples on Dave's Brain is licensed under the
Creative Commons Attribution 2.5 License.
other material, including English text has all rights reserved.