for the number = 1 099 511 627 776 ,output of __builtin_popcount should be 1, but it is 0 here
binary of 1 099 511 627 776 =
0b10000000000000000000000000000000000000000
using n&n-1 works fine, for this number.
Why such unexpected output?
for the number = 1 099 511 627 776 ,output of __builtin_popcount should be 1, but it is 0 here
binary of 1 099 511 627 776 =
0b10000000000000000000000000000000000000000
using n&n-1 works fine, for this number.
Why such unexpected output?
hello @arvinder
buitin popcount works for interger datatype only.
the input ur are giving is greater than the range of int thats why it is giving this weird output.
Thanks, later i used __builtin_popcountll(), it worked well