root with pow() not working

I'm trying to evaluate the root of a integer with pow() but it always return me '1'

1
2
3
4
int a = 0, b = 0;

cin >> a >> b;
cout << pow(a, 1/b) << endl;


can someone tell me why??
Integer division gives you an integer.

What's 1/2? Zero.
http://ideone.com/DkLd6

So what's 1/b (assuming b is some integer greater than zero)? Also zero. What is anything to the power of zero? One.

If you want 1/b to not be zero, do not use an integer for b.
Last edited on
thanks, man!! It's just that I thought: since I'm passing the result of the '1/b' and not assigning the result to b, it should work!!!
But, thank you!!
since I'm passing the result of the '1/b'


The result of 1/b is an integer, whether you assign it or not. The compiler does not have some secret "super-accurate" number that it keeps track of behind the scenes.
Topic archived. No new replies allowed.