def len_hi

mylsm-lsm-store@0.6.0.1 · src/hub_sha/core.bend:788

import mylsm-lsm-store@0.6.0.1/src/hub_sha/core.bend as Core
import Base

788# Big-endian words of the 64-bit message bit length 8n, computed from n with
789# exactly the digit expressions bit_length produces, but without building and
790# matching an eight-element list. bit_length(n) is [o(d6), .., o(d0), low]
791# where d0 = n / 32, d(k+1) = dk / 256 and o(x) = x mod 256.
792def len_hi(+byte_length: Nat) -> U32:
793  +d0 = Nat.div(byte_length, 32n)
794  +d1 = Nat.div(d0, 256n)
795  +d2 = Nat.div(d1, 256n)
796  +d3 = Nat.div(d2, 256n)
797  +d4 = Nat.div(d3, 256n)
798  +d5 = Nat.div(d4, 256n)
799  +d6 = Nat.div(d5, 256n)
800  pack(U32.from_nat(Nat.mod(d6, 256n)), U32.from_nat(Nat.mod(d5, 256n)),
801    U32.from_nat(Nat.mod(d4, 256n)), U32.from_nat(Nat.mod(d3, 256n)))

Uses (6)

Used by (64)