want.to.be.professer
11/8/2008 12:11:00 PM
On 11?8?, ??5?37?, questions <mengqidhu...@yahoo.cn> wrote:
> Today when I build a program,the compiler tells me there is no
> error,but when I run it ,it shows " 1.#INF00000",what's the
> meaning??????The program is as follows:
> #include<stdio.h>
> int main()
> { int x,y;
> int w=0;
> long double z=0;
>
> for(x=0;x<=10;x++)
>
> {if(x==0)
>
> {w=1;}
>
> else
>
> {for(y=1;y<=x;y++)
>
> {w*=y;} }
>
> z+=(float)1/w;}
>
> printf("%.9Lf",z);
>
> return 0;}
overflow!!!
You can see by this:
#include<stdio.h>
int main()
{
int x,y;
int w=0;
long double z=0;
for(x=0;x<=10;x++)
{
if(x==0)
{
w=1;
}
else
{
for(y=1;y<=x;y++)
{
w*=y;
}
}
printf( " w : %d \n", w );
z+=(float)1/w;
printf("%.9Lf\n",z);
}
printf("%.9Lf\n",z);
return 0;
}