1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<TITLE>MATH_CountLeadingZeros</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">MATH_CountLeadingZeros<img src="../../image/NTR.gif"align="middle"><img src="../../image/TWL.gif" align="middle"></H1>
12<H2>Syntax</H2>
13<DL>
14  <DD>
15  <PRE><CODE>#include &lt;nitro/math.h&gt;</CODE></PRE>
16  <PRE><CODE>u32 MATH_CountLeadingZeros( u32 x );
17u32 MATH_CLZ( u32 x );
18
19  </CODE></PRE>
20</DL>
21<H2>Arguments</H2>
22<TABLE border="1">
23  <TBODY>
24    <TR>
25<TD><B><I>x</I></B></TD>
26<TD>Numeric value to evaluate</TD>
27    </TR>
28  </TBODY>
29</TABLE>
30<H2>Return Values</H2>
31<P>The number of sequential 0 bits, starting from the highest-order bit.</P>
32<H2>Description</H2>
33<P>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 <CODE>0x80000000</CODE> returns 0, and a value of 0 returns 32. The internal implementation is such that the function is an inline function wrapping a <code>CLZ</code> command that can be used with ARM9 ARM code. It is expanded as one instruction by the compiler. In ARM7 and ARM9 THUMB code, the standard function is called.<br>For this reason, if your program internally switches between ARM and THUMB code, do not use <code>#pragma thumb on</code>. Instead use <code>#include &lt;twl/code16.h&gt;</code>.<br>See the <a href="../../information/headerfiles.html">Description of Header Files</a> page for a description of <CODE>code16.h</CODE>.
34</P>
35<P><CODE>MATH_CLZ</CODE> is another name for the <CODE>MATH_CountLeadingZeros</CODE> function.</P>
36<P>To count the number of consecutive 0's from the end, use the <A href="../bit/MATH_CountTrailingZeros.html"><CODE>MATH_CountTrailingZeros</CODE></A> function.</P>
37<H2>See Also</H2>
38<P><A href="../bit/MATH_CountTrailingZeros.html"><CODE>MATH_CountTrailingZeros</CODE></A><BR> <A href="../int/MATH_ILog2.html"><CODE>MATH_ILog2</CODE></A></P>
39<H2>Revision History</H2>
40<P>
412009/04/28 Described the method for switching to THUMB mode.<br>
42 2006/01/10 Added missing links.<br> 2005/12/22 Added a link to the <CODE>MATH_CountTrailingZeros</CODE> function.<br> 2005/06/02 Corrected &quot;&amp;&quot; notation.<BR> 2004/12/14 Initial version.</P>
43<hr><p>CONFIDENTIAL</p></body>
44</HTML>
45