Skip to content

Instantly share code, notes, and snippets.

@hirokuma
Created July 8, 2018 15:27
Show Gist options
  • Save hirokuma/f365c2a85dae3962ff3d5f19562b9029 to your computer and use it in GitHub Desktop.
Save hirokuma/f365c2a85dae3962ff3d5f19562b9029 to your computer and use it in GitHub Desktop.
import java.math.BigInteger;
public class Main {
static void func(long value) {
BigInteger val = new BigInteger(Long.toHexString(value), 16);
System.out.println("BigInteger: " + val);
BigInteger byteVal = val.shiftRight(56);
System.out.println("BigInteger 2byte: " + byteVal);
}
public static void main(String[] args) {
long decLong = 0xFEDCBA9876543210L;
System.out.println("long: " + decLong);
System.out.println("long 2byte: " + (decLong >> 56));
func(decLong);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment