Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Improve uint_to_hash() #2

@flexatone

Description

@flexatone

This is presently using an simple division by 2, which is not ideal.

Some ideas from Chat GPT:

int64_t hash_uint64_to_int64(uint64_t value) {
    return (value ^ INT64_MIN) & 0xFFFFFFFFFFFFFFFF;
}

int64_t hash_uint64_to_int64(uint64_t value) {
    uint64_t xor_shifted = value ^ (value >> 32);
    return (int64_t)(xor_shifted - INT64_MIN);
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions