BCD

From C64-Wiki
Jump to navigationJump to search

BCD (Binary Coded Decimal) is data representation where decimal digits are encoded separately, each taking a nibble, so one byte is capable of carry two decimal digits which covers a value range from decimal 00 to 99. This kind of encoding is used in areas with exact representation of decimal values (in financials and accounting) ensures correct calculations without rounding problems know from the otherwise commonly used floating point arithmetic.

The C64 CPU and the 6502 processor family in general provide a decimal mode which allows additions and subtractions to be processed in decimal logic. There is a separate status flag, the decimal flag to indicate the decimal mode with the flag set to 1. In contrary to some other CPUs there is no separate adjust instruction for mapping the result back to the BCD format after an arithmetic operation happened in normal binary mode.

Links[edit | edit source]

WP-W11.png Wikipedia: BCD