Skip to content
systemcoding.dev

Snippets

Short posts that solve one thing: the code, the output we got, and why it works.

Fundamentals

Count trailing zeros with __builtin_ctz

Count trailing zeros in C with __builtin_ctz on GCC and Clang, and guard the zero case, because the builtin is undefined for an input of 0.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.