def significant_bits
import stelliferous@0.0.2.0/storage_buffer.bend as StorageBufferimport Base
43# Shared runtime depth calculation. The tail call stops at the significant
44# word bits; allocation_depth remains the arithmetic model used by proofs.
45def significant_bits(remaining: Nat,+value: U32,+bits: Nat,zero: Bool) -> Nat:
46 match remaining zero:
47 case 0n zero: bits
48 case 1n+rest True{}: bits
49 case 1n+rest False{}:
50 +next = U32.shr(value)
51 significant_bits(rest,next,1n+bits,U32.is_zero(next))