Bonus Puzzle

BCS ao at pathlink.com
Wed Aug 6 17:14:25 PDT 2008


Reply to wyverex,

> Through another one in....
> 
> (Multiply x by 7 without using multiplication (*) operator.)
> 
> Bonus Problem!
> Multiply X by Y without using multiplication (*) operator..  Faster
> the
> better!!!

int Mul(int i, int j)
{
   int ret = 0;
   while(j)
   {
      if(j & 0x01) ret += i;
      j >>= 1;
      i <<= 1;
   }
   return ret;
}


now do div :)




More information about the Digitalmars-d-learn mailing list