Binary coded decimal

Library to de- and encode binary coded decimals.

uint8_t bcd_from_byte(uint8_t byte)

Converts a byte to a binary coded decimal.

Parameters

byte:A byte

Return values

  • A binary coded decimal (4 MSB = 10s, 4 LSB = 1s)
uint8_t bcd_to_byte(uint8_t bcd)

Converts a binary coded decimal to a byte.

Parameters

bcd:A binary coded decimal (4 MSB = 10, 4 LSB = 1s)

Return values

  • A byte