Count leading zeros

The clz instructions, short for count leading zeros, are used to count the amount of zeros at the start of the numbers binary representation.

Try it

Syntax

wasm
;; load a number onto the stack
i32.const 8388608 ;; 00000000_10000000_00000000_00000000

;; count leading zeros
i32.clz

;; the top item on the stack will now be 8
Instruction Binary opcode
i32.clz 0x67
i64.clz 0x79