考虑以下联合:
union Uint16Vect {
uint16_t _comps[4];
uint64_t _all;
};
Run Code Online (Sandbox Code Playgroud)
是否有快速算法来确定每个组件是否等于1模12?
一个天真的代码序列是:
Uint16Vect F(const Uint16Vect a) {
Uint16Vect r;
for (int8_t k = 0; k < 4; k++) {
r._comps[k] = (a._comps[k] % 12 == 1) ? 1 : 0;
}
return r;
}
Run Code Online (Sandbox Code Playgroud)