DODONG

博客园 首页 新随笔 联系 订阅 管理

 一直以来都没有关注过算法,看数的时候运算符那一栏基本略过,今天刚巧碰上用到幂的次方算法, ^ 号原来在C#中居然是“异或”和在VB中区别太大了,这个问题在后来才被一同事发现.


C#写法

string TxtRights ="";
 CurRight
=0;
for(int i=0;i< 5;i++)
   
{
    
if ( ((Convert.ToInt32(Rights) &  (int)Math.Pow(2,i)) ==(int)Math.Pow(2,i); ))
    
{
     CurRight
= (int)Math.Pow(2,i);;
     TxtRights 
= TxtRights+","+ CurRight;
    }

   }

----------------------------------Rights ------
VB写法
TxtRights
=""
For i
=0 To 12
 If (Rights And (
2^i))<>0 Then
 CurRight
=2^i
 TxtRights
=TxtRights&","&CurRight
End If
Next 
posted on 2006-05-24 23:48  DODONG  阅读(475)  评论(0编辑  收藏  举报