rendered paste bodyint *convertToBin(uint8_t decimal)
{ int i, count =1,tmp_count,new_decimal;
new_decimal = decimal;
if( (decimal % 2) == 1) {
decimal = decimal -1;
// zero =1;
}
while(decimal > 1)
{
decimal = decimal /2;
count++;
}
printf("cislo ma %d mist \n",count);
int *p_char;
if((p_char=(int *)malloc(count))==NULL)
{
printf("Memory allocation has failed");
}
bzero(p_char,count);
int base =2;
int pom,pom1;
for(i=0;i<count;i++)
{ pom = base<<(count-2-i);
printf("Ma se odecist %d \n",pom);
if(new_decimal - pom >= 0)
{
p_char[i]=1;
new_decimal = new_decimal - pom;
}
if(new_decimal == 0) return p_char;
}
return p_char;
}