Difference between revisions of "Converting Binary Coded Decimal"

From BeebWiki
Jump to: navigation, search
m (1 revision)
m
Line 1: Line 1:
[[Category:BASIC]]
+
[[Category:BASIC]][[Category:Programming tips]]
 
'''B'''inary '''C'''oded '''D'''ecimal (BCD) is a method of representing a decimal number as a hexadecimal value using the hex digits 0-9 and ignoring A-F. For example, the number 21 (hex &15) would be represented as &21 (decimal 33). It can be a convenient internal representation of decimal numbers as each hexadecimal digit can be displayed without any further processing. See [http://en.wikipedia.org/wiki/Binary-coded_decimal Wikipedia].
 
'''B'''inary '''C'''oded '''D'''ecimal (BCD) is a method of representing a decimal number as a hexadecimal value using the hex digits 0-9 and ignoring A-F. For example, the number 21 (hex &15) would be represented as &21 (decimal 33). It can be a convenient internal representation of decimal numbers as each hexadecimal digit can be displayed without any further processing. See [http://en.wikipedia.org/wiki/Binary-coded_decimal Wikipedia].
 
BCD values can be decoded with:
 
BCD values can be decoded with:

Revision as of 21:17, 3 July 2016

Binary Coded Decimal (BCD) is a method of representing a decimal number as a hexadecimal value using the hex digits 0-9 and ignoring A-F. For example, the number 21 (hex &15) would be represented as &21 (decimal 33). It can be a convenient internal representation of decimal numbers as each hexadecimal digit can be displayed without any further processing. See Wikipedia. BCD values can be decoded with:

     number% = VALSTR$~bcd%

Numbers can be encoded in BCD using:

     bcd% = EVAL("&"+STR$number%)

Jgharston 21:11, 23 June 2007 (BST)