"pow is a double function" is this the correct explanation if yes then why does sometimes it shows this type of error, why not every time while using it in a loop...
this is a code of decimal to binary converter, when I use the round function then it shows the right answer otherwise not
int n, a;
cin >> n;
int ans = 0;
int i = 0;
while (n != 0) {
int bit = n & 1;
a = bit * pow(10, i);
cout << bit * pow(10, i) << " " << a << endl;
ans = ans + a;
cout << ans << endl;
n = n >> 1;
i++;
}
cout << " Answer is " << ans << endl;