diff --git a/include/mesytec-mnode/mnode_math.h b/include/mesytec-mnode/mnode_math.h new file mode 100644 index 0000000..a9693c2 --- /dev/null +++ b/include/mesytec-mnode/mnode_math.h @@ -0,0 +1,18 @@ +#ifndef C536E080_25D7_476D_B8E3_25912B9CFC3B +#define C536E080_25D7_476D_B8E3_25912B9CFC3B + +#include + +namespace mesytec::mnode +{ +// round n up to the nearest multiple of p +// source: https://blog.xoria.org/rounding-up/ +inline int64_t round_up(int64_t n, int64_t p) +{ + int64_t mask = p - 1; + return (n + mask) & ~mask; +} + +} + +#endif /* C536E080_25D7_476D_B8E3_25912B9CFC3B */