Function
pow () gives very strange outputs.
I tried various combinations:
#include<stdio.h> #include<math.h> int main() { int d=1; long long n1,n2; while(d<10) { n1=pow(10,d); n2=pow(10,d); d++; printf("%lld %lld\n",n1,n2); } }
this gives an incorrect conclusion, i.e. 99 instead of 100, etc.
Now, if I delete one of the variables, ans. right. if instead of d, I use a constant, ans correctly. if I accept n1 and n2 as double, ans is correct.
Thus, the presence of two pow () functions with both variables as power and type cast as integers gives a poor result. Why is this weird behavior?
c ++ c
Aman Gupta Jun 15 '13 at 10:12 2013-06-15 10:12
source share