]>
git.ipfire.org Git - people/ms/u-boot.git/blob - include/bcd.h
1 /* Permission is hereby granted to copy, modify and redistribute this code
2 * in terms of the GNU Library General Public License, Version 2 or later,
6 /* inline functions to translate to/from binary and binary-coded decimal
7 * (frequently found in RTC chips).
13 static inline unsigned int bcd2bin(unsigned int val
)
15 return ((val
) & 0x0f) + ((val
& 0xff) >> 4) * 10;
18 static inline unsigned int bin2bcd(unsigned int val
)
20 return (((val
/ 10) << 4) | (val
% 10));