十进制转二进制快速算法
int print_binary(int value){
int i = 8;
while(i>=0)
{
// printf('i_1 is %d\n', i_1);
int P_1 = pow(2, (i+1));
// printf('P_1 is %d\n', P_1);
int P = pow(2, i);
// printf('P is %d\n', P);
// printf('calculation is %d\n\n', ((value%(P_1))));
if (((value%(P_1))&P) == P)
{
printf('1');
}
else
{
printf('0');
}
i--;
}
}
赞17
踩0