写了一个求π的代码,可是结果是0.望大家帮帮忙,看看错哪了

写了一个求π的代码,可是结果是0.望大家帮帮忙,看看哪里错了。
我在自学C++,看到求π题,想自己写一下,可是结果怎么都不对。请大家看看是我的想法错了,还是代码错了
这是我的代码
C/C++ code

#include<iostream>
using namespace std;

double arctan(double x);
double power(double x,int n);

void main()
{
    double a,b;
    a=16.0*arctan(1/5.0);
    b=4.0*arctan(1/239.0);
    cout<<"pi is "<<a-b<<endl;

}

double power(double x, int n)
{
    double val=1.0;
    while (n--)
        val=val*x;
    return (val);
}

double arctan(double x)
{
    int i,e;
    double arct;
    arct=0.0;
    i=1;
    e=x;
    while (e/i>1e-15){
        arct+=power(x,2*i-1)/(power((-1.0),i+1)*(2.0*i-1.0));
        i++;
    }
    return (arct);
}



谢谢大家了。

------解决方案--------------------
int e;
e = x;
x是double型,e是int型,当x是小数时赋值给e,e直接就为0了。
------解决方案--------------------
double arctan(double x)
{
int i,e; //这里的变量e应该为double类型,不然下面的表达式e = x;就会使x的值被截断变成0了。
double arct;
arct=0.0;
i=1;
e=x; //注意这儿要使e的类型为double.
while (e/i>1e-15){ //不如把这儿的1e-15改成1e-6这样减少了精度,但提高的执行速度。其实1e-6可以理解为等于0.0了.
arct+=power(x,2*i-1)/(power((-1.0),i+1)*(2.0*i-1.0));
i++;
}
return (arct);
}
还有一个问题是你的程序由于条件是>1e-15所以程序循环的次数比较大,程序会执行5~10分钟才能出结果。不过结果是正确的。3.14159