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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -