[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
BCD_Format
BCD (Binary Coded Decimal) is a format for storing numbers, commonly used in some BIOS implementations.
BCD stores the 10-digit in the upper nibble and the 1-digit in the lower nibble - e.g. 12 decimal in BCD is 0x12 (=18).
C code for converting BCD to decimal and vice versa:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
BCD_Format
BCD (Binary Coded Decimal) is a format for storing numbers, commonly used in some BIOS implementations.
BCD stores the 10-digit in the upper nibble and the 1-digit in the lower nibble - e.g. 12 decimal in BCD is 0x12 (=18).
C code for converting BCD to decimal and vice versa:
int bcd(int dec)
{
return ((dec/10)<<4)+(dec%10);
}
int unbcd(int bcd)
{
return ((bcd>>4)*10)+bcd%16;
}
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
