AceCommon
1.1
Arduino library for low-level common functions and features with no external dependencies
|
Go to the documentation of this file.
33 #ifndef ACE_COMMON_ARITHMETIC_H
34 #define ACE_COMMON_ARITHMETIC_H
38 namespace ace_common {
66 return (val / 10 * 16) + (val % 10);
71 return (val / 16 * 10) + (val % 16);
96 inline unsigned long udiv1000(
unsigned long n) {
97 unsigned long x = (n >> 8);
98 unsigned long y = (x >> 8);
99 unsigned long z = (y >> 8);
100 return (x >> 2) + 3 * (y >> 1) + 9 * z;
uint8_t bcdToDec(uint8_t val)
Convert binary coded decimal to normal decimal numbers.
void incrementModOffset(T &d, T m, T offset)
Increment 'd' mod 'm', with an offset, avoiding '' operator which is expensive for 8-bit processors.
void incrementMod(T &d, T m)
Increment 'd' mod 'm', avoiding '' operator which is expensive for 8-bit processors.
unsigned long udiv1000(unsigned long n)
Approximate division by 1000 without using integer division to avoid inefficient integer division ope...
uint8_t decToBcd(uint8_t val)
Convert normal decimal numbers to binary coded decimal.