i am trying to count number of bits in 64 bit integer but it shows some unexpected.here is the code. counting bits is was not the major part but some unexpected output is....plz have a look on input and output!!!!
#include<iostream>
#include<math.h>
#include<stdint.h>
#include<cstdio>
using namespace std;
int64_t t,n,ans;
int main(){
cin>>t;
while(t--){
int64_t ans=0;
cin>>n;
/*
while(n>0LL){
n>>=1LL;
ans++;
}//*/
ans=floor(log2(n));
//ans=floor(log2l(n));
cout<<ans<<"\n";
}
return 0;
}
the input and output is this
10
18446744073709551615
63 (number of bits in 18446744073709551615) should be printed only once and console should be waiting till i input another number and the count the number of bits in other number.but it is not happening.The output comes is like this....
63
63
63
63
63
63
63
63
63
63
plz help me ragarding the same.