def halvings
import bendtorch-core@0.1.0.0/src/tensor/matmul.bend as Matmulimport Base
317# floor(log2(number)) for a positive number, 0 for 0. `fuel` bounds the
318# halvings; `number` itself is enough.
319def halvings(fuel: Nat, +number: Nat) -> Nat:
320 match fuel:
321 case 0n:
322 0n
323 case 1n+rest:
324 halvings_step(n => halvings(rest, n), number, Nat.is_lt(number, 2n))