# MATH_CountLeadingZeros

## Syntax

      #include <nitro/math.h>

      u32 MATH_CountLeadingZeros( u32 x );
      u32 MATH_CLZ( u32 x );

## Arguments

x | The value to scan

## Return Values

The number of sequential `0` bits, starting from the highest order bit.

## Description

This function scans the data of a 32-bit quantity and reports the number of sequential bits that are set to 0 beginning at the highest-order bit. For example, a value of 0x80000000 will return 0, and a value of 0 will return 32. The internal implementation is such that the function is an inline function wrapping a `CLZ` command that can be used with ARM9 ARM code. It is expanded as one instruction by the compiler. For ARM7 and also for ARM9 Thumb code, the normal function gets called.

`MATH_CLZ` is another name for the `MATH_CountLeadingZeros` function.

To count the number of consecutive `0`'s from the end, you can use the `MATH_CountTrailingZeros` function.

## See Also

`MATH_CountTrailingZeros, MATH_ILog2
`

## Revision History

2006/01/10 Added missing links
2005/12/22 Added a link to the `MATH_CountTrailingZeros` function.
2005/06/02 Changed `&` to `&amp;`.
2004/12/14 Initial version.

CONFIDENTIAL