I am working on a little decentralized game with a world made of plots. It has a map which links a location to a Plot struct. A location is saved as a bytes16 but represents two int64 (coordinates can be negative and the center is in 0, 0). How can I convert them to int64 (it seems I can only convert them to uint64)?
Here is what I tried:
function convertToCoordinates(bytes32 input)
public
pure
returns (uint128 x, uint128 y)
{
bytes16 xbytes;
bytes16 ybytes;
(xbytes, ybytes) = split(input);
x = int128(int128(uint128(xbytes)) - 2**127 - 1);
y = int128(int128(uint128(ybytes)) - 2**127 - 1);
}