Morton encoding and decoding functions