Trying to test precision making a sum from 1 to a million but my output keeps coming out as inf.
#include <stdio.h>
int main()
{
float x=0.0 ;
double y =0.0;
int i;
for(i=1; i<100000; i = i+1)
{
x=(float) x+( 1.0f/(3.0f*(float)(i*i)));
y=(double) y+ ( 1.0/(3.0*(double)(i*i)));
}
printf("Natural Order \n");
printf("Single Precision: ");
printf("%f", x);
printf("\n");
printf("Double Precision: ");
printf("%lf", y);
printf("\n");
}
I have changed i range many times but still getting inf as my output.