Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Fix long to bytes conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
dheid committed Oct 30, 2023
1 parent 703d6ba commit b5e5437
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public static VisitorId random() {
*/
public static VisitorId fromHash(long hash) {
VisitorId visitorId = new VisitorId();
for (int i = 0; i < 7; i++) {
visitorId.representation[i] = (byte) (i + hash & 0xFF );
hash >>= 8;
for (int i = Long.BYTES - 1; i >= 0; i--) {
visitorId.representation[i] = (byte) (hash & 0xFF);
hash >>= Byte.SIZE;
}
return visitorId;
}
Expand Down

0 comments on commit b5e5437

Please sign in to comment.