Question: please help me for my coding. I want to make a program like this. sorry bad english. 

Given input: 

```
N  
where N is an integer. 

```

return: 

```
True  if N = 2^x, where x is an integer.

```

I've tried to do this but it doesn't work as i want.

```
using namespace std;
int main()
{
    float a,b,c;
    cin>>a;
    c=log10(a)/log10(2.0);
    b=pow(2,c);
    if(b==a)
    {
        cout<<"TRUE"<<endl;}
    else
        cout<<"FALSE"<<endl;{
    }
}

```

Help me please. Thank you.

Answer: 
As [What Every Computer Scientist Should Know About Floating-Point Arithmetic](http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html) explains, floating point numbers in computer programs pretend they can represent any real number, but actually have only 32 or 64 bits, so you will get rounded off to the nearest representation. Even numbers that look simple, like 0.1, have an endless representation in binary and so will get rounded off. Functions that operate on floating point numbers like `cos` and `pow` will, by their nature, sometimes give you the 'wrong' result simply because the 'right' result is not a representible floating point.

Sometimes the solution is complex. However in this case the solution is quite simple - check that the two numbers' difference is less than epsilon, where epsilon is a small enough number to give you the accuracy you need. e.g.

```
float epsilon = 0.0001;
if(abs(b-a) < epsilon)

```

Also, whenever you need accuracy more than speed and size, use `double` in preference to `float`. It's twice as big and thus many significant places more precise.
Declare the values a,b,c as double if you want to use this
c=log10(a)/log10(2.0);

Declare the values a,b,c as float if u want to use this 
c=log10(a)/log10(2.0f);

I executed the program with both these changes ,one by one .Its working for both 
check the syntax and example [here](http://www.cplusplus.com/reference/cmath/log10/)