Decimal "08" gets coded in binary as "0000 1000", that's because the hexadecimal representation of the number is also "08".

but

Decimal "39" does *not *get coded as "0011 1001", because its hexadecimal representation is "27" (thus binary "0010 0111").

There is however a coding system called BCD (Binary Coded Decimal) which would code "39" exactly as "0011 1001". In other words BCD does with *decimals* what you'd normally do with *hexadecimals*, i.e. take each digit and "translate" it to a half-a-byte (a *nibble*) binary number. As only values from 0 to 9 can be represented by a decimal digit, only binary values from 0000 to 1001 can be "translated" (1010 to 1111 remain unused).

While this is mostly a relict of "old times" there are still areas where BCD is used. A good example are digital clocks, since some chips translate directly binary digits into 0-9 digits, without having to worry about characters like A-F, which would be present if translating to hexadecimals. Or, and that is how I learned about the existence of BCD, in some digital controls for lighting devices (DALI standard).

This topic on Wikipedia.

< Prev | Next > |
---|