Is there a simple way to map i64 <-> u64 such that:
-
for values they both represent, the maping preserves value
-
the mapping is 1-1
?
Is there a simple way to map i64 <-> u64 such that:
for values they both represent, the maping preserves value
the mapping is 1-1
?
You can convert between them using as
which effectively transmute them and has those 2 properties you mentioned.
The mapping used by as
casting or other bit-for-bit reintepretation in Rust is two's complement.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.