Skip to content

Instantly share code, notes, and snippets.

@hirokuma
Created July 8, 2018 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirokuma/c8a67b1db8e44ce45236942088d81865 to your computer and use it in GitHub Desktop.
Save hirokuma/c8a67b1db8e44ce45236942088d81865 to your computer and use it in GitHub Desktop.
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
//0xFEDCBA9876543210
BigDecimal dec = new BigDecimal("18364758544493064720");
BigDecimal div = dec.divide(new BigDecimal("72057594037927936"));
System.out.println("big decimal 2byte: " + Integer.toHexString(div.intValue()));
long decLong = 0xFEDCBA9876543210L;
System.out.println("long 2byte: " + Long.toHexString(decLong >>> 56));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment