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_ILog2</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">MATH_ILog2 <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>int MATH_ILog2( u32 x );
17
18  </CODE></PRE>
19</DL>
20<H2>Arguments</H2>
21<TABLE border="1">
22  <TBODY>
23    <TR>
24      <TD><B><I>x</I></B></TD>
25      <TD>The numeric value for which log will be computed</TD>
26    </TR>
27  </TBODY>
28</TABLE>
29<H2>Return Values</H2>
30<P>The integer part of the log to the base 2 of <em><strong><code>x</code></strong></em>, where <em><strong><code>x</code></strong></em> is non-zero. In the special case where <nobr><em><strong><code>x</code></strong></em><code> = 0</code></nobr>, the value <code>-1</code> is returned.</P>
31<H2>Description</H2>
32<P>This function calculates the log to the base 2 for the specified value and returns the integer part of the result. This computation yields the same result as a computation that searches for the location of the first standing bit in <em><strong><code>x</code></strong></em>. But because this is a logarithm, the value in the argument must be a positive number. If the argument holds <code>0</code>, the function returns <code>-1</code>.</P>
33<P>For the ARM9 ARM code, which supports CLZ commands, the function becomes an inline function that computes <nobr><code>31 - clz(x)</code></nobr>, so it can be executed in two commands. For the ARM9 Thumb code and the ARM7, the function is implemented as a normal function.</P>
34<H2>See Also</H2>
35<P><CODE><A href="../bit/MATH_CountLeadingZeros.html">MATH_CountLeadingZeros</A><BR></CODE></P>
36<H2>Revision History</H2>
37<P>2004/12/14 Initial version.</P>
38<hr><p>CONFIDENTIAL</p></body>
39</HTML>
40