AceCommon
1.4.5
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 {
69 uint8_t tens = val / 10;
70 uint8_t ones = val - tens * 10;
71 return (tens * 16) + ones;
84 return (val / 10 * 16) + (val % 10);
97 #if defined(ARDUINO_ARCH_AVR)
111 return (val / 16 * 10) + (val % 16);
137 unsigned long x = (n >> 8);
138 unsigned long y = (x >> 8);
139 unsigned long z = (y >> 8);
140 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.
uint8_t decToBcdDivMod(uint8_t val)
A version of decToBcd() that uses a division and a modulus operation.
void incrementMod(T &d, T m)
Increment 'd' mod 'm', avoiding '' operator which is expensive for 8-bit processors.
uint8_t decToBcdDivOnly(uint8_t val)
A version of decToBcd() that uses only a single division operation.
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.