Wednesday, 18 September 2013

Displaying Digits Beginning from 0.000000001 to 0.999999999 in C

Displaying Digits Beginning from 0.000000001 to 0.999999999 in C

I'm trying to print out the numbers mentioned in the title with a loop
with the following code:
#include <stdio.h>
int ceiling = 1;
float counter = 0;
int main()
{
while (counter < ceiling)
{
printf("%f\n", counter);
counter = counter + 0.000000001;
}
}
but it only gives me 7 digits of precision. Is there any way to get 10
digits of precision?

No comments:

Post a Comment