Syntax:
BcdToDec_GCB ( ByteVariable )
Command Availability:
Available on all microcontrollers.
Supports bytes only.
Explanation:
Converts numbers from Binary Coded Decimal (BCD) format to decimal. In BCD, each nibble (4 bits) of a byte represents one
decimal digit — for example, the BCD byte 0x23 represents the decimal number 23, not 35.
This is not a built-in GCBASIC command; it is a user-defined function you add to your own program and call when needed.
Example:
Function BcdToDec(va) as byte
BcdToDec=(va/16)*10+va%16 ' <<< the BcdToDec instruction
End FunctionKey line: BcdToDec=(va/16)*10+va%16 — treats the high nibble of va (va/16) as the tens digit and the low nibble (va%16) as the units digit, combining them into an ordinary decimal value.
See Also:
- DecToBcd_GCB — the inverse conversion

