G
Gopal
Hello:
Can anybody suggest a code or modify the following chunk of
code for converting a decimal to BCD and viceversa for unsigned long
integers. The following code works good for integers but fails for
unsigned long.
int bcd(int dec)
{
return ((dec/10)<<4)+(dec%10);
}
int decimal(int bcd)
{
return ((bcd>>4)*10)+bcd%16;
}
Thanks
Gopal
Can anybody suggest a code or modify the following chunk of
code for converting a decimal to BCD and viceversa for unsigned long
integers. The following code works good for integers but fails for
unsigned long.
int bcd(int dec)
{
return ((dec/10)<<4)+(dec%10);
}
int decimal(int bcd)
{
return ((bcd>>4)*10)+bcd%16;
}
Thanks
Gopal