Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
imath.h
Go to the documentation of this file.
1#ifndef HUMIDISTAT_IMATH_H
2#define HUMIDISTAT_IMATH_H
3
9template<typename T>
10constexpr T ipow(T base, unsigned int pow) {
11 return (pow >= sizeof(unsigned int) * 8) ? 0 : pow == 0 ? 1 : base * ipow(base, pow - 1);
12}
13
17constexpr unsigned int ilog10(int n) {
18 if (n <= 1) {
19 return 0;
20 } else {
21 return ilog10(n / 10) + 1;
22 }
23}
24
25#endif //HUMIDISTAT_IMATH_H
constexpr unsigned int ilog10(int n)
Constexpr integer base-10 logarithm.
Definition imath.h:17
constexpr T ipow(T base, unsigned int pow)
Constexpr function for computing integer power.
Definition imath.h:10