位运算实现小正整数乘法

    public static int multiple(int a,int b)
    {
        int result=0;
        int c=0;
        while(b!=0)
        {
            if((b&0x01)==1)
            {
                result+=a<<c;
            }
            b>>=1;
            c++;
        }
        return result;
    }

 

posted @ 2015-09-21 10:44  Maydow  阅读(193)  评论(0编辑  收藏  举报