summaryrefslogtreecommitdiffstats
path: root/qemu/include/qemu/bcd.h
blob: b4c9b64b8f9b205d330776c021e33a1238b3eb72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef QEMU_BCD_H
#define QEMU_BCD_H 1

/* Convert a byte between binary and BCD.  */
static inline uint8_t to_bcd(uint8_t val)
{
    return ((val / 10) << 4) | (val % 10);
}

static inline uint8_t from_bcd(uint8_t val)
{
    return ((val >> 4) * 10) + (val & 0x0f);
}

#endif