添加函数 MathUtil::popcount,用于计算一个数字中二进制1的个数

This commit is contained in:
2025-08-07 22:35:10 +08:00
parent 09eaa78ba1
commit dd72a8e3fd
3 changed files with 52 additions and 0 deletions
+5
View File
@@ -10,6 +10,11 @@ class MathUtil
public:
static size_t ComponentSize(ComponentType ct);
static size_t DataTypeSize(DataType dt);
//count the number of bits set in v
static DV_CORE_API uint32_t popcount(uint8_t v);
static DV_CORE_API uint32_t popcount(uint16_t v);
static DV_CORE_API uint32_t popcount(uint32_t v);
static bool floatEqual(float a, float b,
float tolerance = std::numeric_limits<float>::epsilon()) {