Friday, 20 October 2006

BCD

It stands for Binary-Coded Decimal. The professor asked me whether i am familiar with the term of maybe even know what does it means. He first asked the class, and when everybody admited that they knew what BCD was, he turned to me and asked, "Even you know BCD?"

Stupidly i answered "Ermm..I am not sure". You see, that's my problem. Sometimes i know the things or equations asked but i just dont remember the names. When he explained what BCD is, i felt so stupid because i was thinking about that earlier. I felt like an idiot the entire hour until the class ends.

So, here's something from Wikipedia.

**************************************************************************


BCD

In computing and electronic systems, Binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence. Its main virtue is that it allows easier conversion to decimal digits for printing or display. Its drawbacks are the complexity of circuits needed to impliment mathematical functions and the space wasted in the encoding - 6 wasted paterns per digit. Even though the importance of BCD has diminished, it is still encountered.

In BCD, a digit is usually represented by four bits which, in general, represent the values/digits/characters 0-9. Other combinations are sometimes used for sign or other indications.

Basics

To BCD-encode a decimal number using the common encoding, each digit is encoded using the four-bit binary bit pattern for each digit. For example, the number 127 would be:

0001 0010 0111

Since most computers store data in eight-bit bytes, there are two common ways of storing four-bit BCD digits in those bytes:

  • each digit is stored in one byte, and the other four bits are then set to all zeros, all ones (as in the EBCDIC code), or to 0011 (as in the ASCII code)
  • two digits are stored in each byte.

Unlike pure binary encodings large numbers can easily be displayed by splitting up the nibbles and sending each to a different character with the logic for each display being a simple mapping function. Converting from pure binary to decimal for display is much harder involving integer multiplication or divide operations. The BIOS (Basic Input/Output Systems) in many PCs keeps the date and time in BCD format, probably for historical reasons (it avoided the need for binary to ASCII conversion).

******************************************************************

I wont forget this the next time. Even if i dont understand everything written up here. Hah!



No comments: