How to convert 8 bytes BCD number to integer ?

Status
Not open for further replies.

crocu

Member
Hello

I need to write a code in C to convert a 8 bytes BCD number to an integer.

ie : (0100 0101) = 45

I wrote this so far, but it won't work
Does someone know why ?

Code:
unsigned int BCD_2_INT(unsigned char bcd_number)
{
unsigned int int_number;
int_number = ((bcd_number >> 4)*10+(bcd_number & 0x0F));
return (int_number);										
}
 
Last edited:
Actually, this code works fine .

I've just needed to redo a 'built all' in my project to clear old stuff, now it works !
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…