Closed lurenjia528 closed 1 year ago
I know
this is java long type precision lost, The following two methods are ok.
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin;
...
long value = streamingXXHash64.getValue();
BigInteger bigInteger = BigInteger.valueOf(value);
return HexBin.encode(bigInteger.toByteArray()).toLowerCase();
public static String printHexString(byte[] b) {
String res = "";
for (int i = 0; i < b.length; i++) {
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
res += hex;
}
return res;
}
long l = 497568829116747426L;
this long value to hex should be 06e7b836becf8ea2
but Long.toHexString(value).toLowerCase();
is 6e7b836becf8ea2
the result : 6e7b836becf8ea2 The calculation result of some files is 15 bits
go calc the same file, the result is 06e7b836becf8ea2