Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top