move round_up() into mnode_math

This commit is contained in:
Florian Lüke 2024-12-23 12:59:27 +01:00
parent a679f8aca7
commit 2087933fac

View file

@ -0,0 +1,18 @@
#ifndef C536E080_25D7_476D_B8E3_25912B9CFC3B
#define C536E080_25D7_476D_B8E3_25912B9CFC3B
#include <cstdint>
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 */