How to get the 2's complement value of a BigInteger of arbitrary length
问题 Is there a method in BigInteger to get the 2's complement value? For eg: if there is a BigInteger with a negative value BigInteger a = new BigInteger("-173B8EC504479C3E95DEB0460411962F9EF2ECE0D3AACD749BE39E1006FC87B8", 16); then I want to get the 2's complement in a BigInteger form BigInteger b = E8C4713AFBB863C16A214FB9FBEE69D0610D131F2C55328B641D61EFF9037848 I can subtract the first BigInteger from 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF to get the second