@Test public void pairingLongsShouldBeReversible() { def("Arrays.equals(unpair(pair(longs)), asArray(longs))") .forAll(DataProvider.LONG_PAIRS) .suchThat(longs -> Arrays.equals(unpair(makePair(longs)), asArray(longs))) .check(-1, 100_000) .assertIsSatisfied(); }
static BigInteger[] unpair(BigInteger value) { BigInteger[] parts = value.divideAndRemainder(HALF); BigInteger signedHi = toSigned.apply(parts[0]); BigInteger signedLo = toSigned.apply(parts[1]); return new BigInteger[]{signedHi, signedLo}; }
BigIntegerPairing { static BigInteger[] unpair(BigInteger value) { BigInteger[] parts = value.divideAndRemainder(HALF); BigInteger signedHi = toSigned.apply(parts[0]); BigInteger signedLo = toSigned.apply(parts[1]); return new BigInteger[]{signedHi, signedLo}; } }
BigIntegerPairing { static BigInteger[] unpair(BigInteger value) { BigInteger[] parts = value.divideAndRemainder(HALF); BigInteger signedHi = toSigned.apply(parts[0]); BigInteger signedLo = toSigned.apply(parts[1]); return new BigInteger[]{signedHi, signedLo}; }  }
BigIntegerPairing { static BigInteger[] unpair(BigInteger value) { BigInteger[] parts = value.divideAndRemainder(HALF); BigInteger signedHi = toSigned.apply(parts[0]); BigInteger signedLo = toSigned.apply(parts[1]); return new BigInteger[]{signedHi, signedLo}; }   }
BigIntegerPairing { static BigInteger[] unpair(BigInteger value) { BigInteger[] parts = value.divideAndRemainder(HALF); BigInteger signedHi = toSigned.apply(parts[0]); BigInteger signedLo = toSigned.apply(parts[1]); return new BigInteger[]{signedHi, signedLo}; }    }