c++14 - C++ gcc _builtin function gives unexpected answer -


int64_t n=7; after printing __builtin_clz(n) answer 29 rather expected answer 61.

that signature intrinsic using:

int __builtin_clz (unsigned int x)

as can see works on 32-bit unsigned. treat 64 bit integer 32 one. since 7 has 4 bits set return 32-3 = 29

try __builtin_clzl; or __builtin_clzll instead.

details here


Comments

Popular posts from this blog

go - serving up pdfs using golang -

python - Best design pattern for collection of objects -

r - Using `bbmle:mle2` with vector parameters (already works using `optim`) -