Hi all,

i create this code for some conversion but i dont know waht is the mistake is present dere,
loop is not return,

please chk this code.

Code:
//here i pass

Value=72;
digits=7;

CString PDU::Bin(int Value, short digits)
{
	CString Bin;
	//#define def_Bin
//#ifdef def_Bin

	CString result; 
	short exponent=0;
     // this is faster than creating the string by appending chars
     result = CString("0"[0],32);
	 do{
		 if (Value & Power2(exponent)) {
             // we found a bit that is set, clear it
             result.Mid(32 - exponent-1, 1);
             Value = Value ^ Power2(exponent);
		 }
         exponent += 1;
	 } while (Value);
	 if (digits < 0) {
         // trim non significant digits, if digits was omitted or negative
         Bin = result.Mid(33 - exponent-1);
	 } else {
         // else trim to the requested number of digits
         Bin = result.Right(digits);
	 }

//#endif // def_Bin

	return Bin;

}
int PDU::Power2(int exponent)
{
	int Power2=0;

//#define def_Power2
//#ifdef def_Power2

	 static int res[31+1];
     int I;

     // rule out errors
     if( exponent < 0 || exponent > 31) /*throw(5);*/
		 //AfxMessageBox("Invalid");

     // initialize the array at the first call
	 if(res[0] = 0) {
         res[0] = 1;
		 for(I = 1;I<30;I++) {
             res[I] = res[I - 1] * 2;
		 }
         // this is a special case
         res[31] = 0x80000000;
	 }

     // return the result
     Power2 = res[exponent];

//#endif // def_Power2


	return Power2;

}
please help me.