float data precision and fat16 lib

When trying to write the value of float variables to a sd card using the write function of the fat16 lib, the precision of the float values is for some reason limited to 2 digits.

Does anyone know how it is possible to write float values with 7 digits precision using the fat16 lib.

Thanks for any help.

As a string, instead?

float someValue = 0.002;
char stringValue[12];
sprintf(stringValue, "%.7f", someValue);

Then, write stringValue to the SD card, instead of someValue;

How about writing the variable to the card, rather than a string representation of it.

I guess that was my problem. How do I do that?

Normally with fwrite, (not knowing which library you're using)

fwrite ( &myFloat, sizeof (myFloat), 1, myStream);