Skydiver, on 12 August 2012 - 12:20 AM, said:
If it's complaining about this line:
It's because uint8_t is only one byte. 0xf64 is 2 bytes. So is 0xf32. So the compiler is warning you about the truncation because it will likely on store 0x64 and 0x32 respectively.
uint8_t bcd[] = {0xf64 , 0xf32};
It's because uint8_t is only one byte. 0xf64 is 2 bytes. So is 0xf32. So the compiler is warning you about the truncation because it will likely on store 0x64 and 0x32 respectively.
thanks.
can the codes above be the same as this bcd to binary program?
I assumed the output of the
uint8_t bcd = 0x42;
bcd -= ((bcd & 0xF0) >> 4) * 6;
printf("%d", bcd);
would be the same as this.
int main()
{
int Num;
int A=0,B=0,C,D,E=1;
int F[100];
printf("Enter the number :");
scanf("%d",&Num);
while(Num>0)
{
A=Num%2;
F[B]=A;
Num=Num/2;
B++;
}
if(B<4)
{
C=B;
for(D=1;D<=4-C;D++)
{
F[B]=0;
B++;
}
}
if(B>4)
{
for(D=0;D<B;D++)
{ if(E==4)
E=1;
else
E++;
}
E--;
if(E<4)
{ for(D=1;D<=4-E;D++)
{
F[B]=0;
B++;
}
}
}
for(E=1,D=B-1;D>=0;D--,E++)
{ printf("%d",F[D]);
if(E==4)
{ printf(" ");
E=0;
}
}
getch();
}

New Topic/Question
Reply




MultiQuote



|