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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -