package wire
Source file uInt64.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28type t = int64 (* Signed on the carrier, unsigned on the field: this is the whole reason the type is abstract. [Int64.compare] reads the top bit as a sign and so ranks 0xFFFF_FFFF_FFFF_FFFF, the largest value here, below zero. Wrong on every target, since nothing about the platform is involved. *) let compare = Int64.unsigned_compare let equal = Int64.equal let zero = 0L let max_int = -1L let pp ppf v = Fmt.pf ppf "%Lu" v let le = Bytes.get_int64_le let be = Bytes.get_int64_be let set_le = Bytes.set_int64_le let set_be = Bytes.set_int64_be let to_int64 v = v let of_int64 v = v let to_int = Int64.to_int let to_int_opt = Int64.unsigned_to_int (* Refuses rather than reinterprets. A negative [int] spells a value above 2^63 as an unsigned 64-bit number, which is not what a caller writing a negative literal meant; [of_int64] is where a bit pattern is reinterpreted on purpose. *) let of_int n = if n < 0 then Fmt.invalid_arg "Wire.UInt64.of_int: %d is not an unsigned 64-bit value" n; Int64.of_int n