bitrev_c.mht

来自「常用的DSP算法集锦」· MHT 代码 · 共 37 行

MHT
37
字号
From: <由 Microsoft Internet Explorer 5 保存>
Subject: 
Date: Wed, 27 Sep 2006 22:45:31 +0800
MIME-Version: 1.0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.oxbad.com/DSP/maindoc/arithmetic_source/c/BITREV.C
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR></HEAD>
<BODY><PRE>/* bitrev.c - bit reverse of a B-bit integer n */

#define two(x)       (1 &lt;&lt; (x))                  /* \(2\sp{x}\) by =
left-shifting */

int bitrev(n, B)
int n, B;
{
       int m, r;

       for (r=3D0, m=3DB-1; m&gt;=3D0; m--)
          if ((n &gt;&gt; m) =3D=3D 1) {                   /* if =
\(2\sp{m}\) term is present, then */
             r +=3D two(B-1-m);                    /* add =
\(2\sp{B-1-m}\) to \(r\), and */
             n -=3D two(m);                        /* subtract =
\(2\sp{m}\) from \(n\) */
             }

       return(r);
}
</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?