I dont know if I'm just having a memory glitch, but the printf format for float is not working as I expect it to.
This example:
#include <stdio.h>
int main()
{
float value;
for(value = 9.990 ;value <= 10.01;value += 0.001)
printf("%02.04f\n", value);
return(0);
}
produces the following output
9.9900
9.9910
9.9920
9.9930
9.9940
9.9950
9.9960
9.9970
9.9980
9.9990
10.0000
10.0010
10.0020
10.0030
10.0040
10.0050
10.0060
10.0070
10.0080
10.0090
The problem is I want to generate a fixed field file so I need an extra digit in the 9.xxxx values. The %02 should give me a minimum field of 2 and I would expect the first value to be 09.9900. I understand that the precesion .04 simply ignores the 0 , but I've been trying everything I can think of. I'm using gcc 3.3.5 on linux and I get the same problem in Dev-C++.
What am I forgetting?
This example:
#include <stdio.h>
int main()
{
float value;
for(value = 9.990 ;value <= 10.01;value += 0.001)
printf("%02.04f\n", value);
return(0);
}
produces the following output
9.9900
9.9910
9.9920
9.9930
9.9940
9.9950
9.9960
9.9970
9.9980
9.9990
10.0000
10.0010
10.0020
10.0030
10.0040
10.0050
10.0060
10.0070
10.0080
10.0090
The problem is I want to generate a fixed field file so I need an extra digit in the 9.xxxx values. The %02 should give me a minimum field of 2 and I would expect the first value to be 09.9900. I understand that the precesion .04 simply ignores the 0 , but I've been trying everything I can think of. I'm using gcc 3.3.5 on linux and I get the same problem in Dev-C++.
What am I forgetting?