Skip to main content

encode_bigint

Function encode_bigint 

Source
pub fn encode_bigint(value: i64) -> [u8; 8]
Expand description

Encodes a BigInt for lexicographic ordering.

Uses sign-flip encoding: XOR the high byte with 0x80 so that negative numbers sort before positive numbers in byte order.

i64::MIN (-9223372036854775808) -> 0x00_00_00_00_00_00_00_00
-1                              -> 0x7F_FF_FF_FF_FF_FF_FF_FF
 0                              -> 0x80_00_00_00_00_00_00_00
 1                              -> 0x80_00_00_00_00_00_00_01
i64::MAX (9223372036854775807)  -> 0xFF_FF_FF_FF_FF_FF_FF_FF