Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/webassembly/reference/numeric/count_trailing_zeros/index.md
6517 views
---
title: Count trailing zeros slug: WebAssembly/Reference/Numeric/Count_trailing_zeros
---

{{WebAssemblySidebar}}

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

{{EmbedInteractiveExample("pages/wat/ctz.html", "tabbed-taller")}}

Syntax

;; load a number onto the stack i32.const 8388608 ;; 00000000_10000000_00000000_00000000 ;; count trailing zeros i32.ctz ;; the top item on the stack will now be 23
InstructionBinary opcode
i32.ctz0x68
i64.ctz0x7a