[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
Links » WxDevCpp » Apple » Rasmus Lerdorf » CCompile » device » register » CSharpandWindowsForms » J2ME » QbasicFAQ_Errors » 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;
}


last edited (May 7, 2003) by ArkLinux, Number of views: 9947, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.