I came across this code recently. It produces strange results (lots of random digits after about the 18th digit.) I tried to find information on the limits to sprintf but could not find it. I am trying to figure out if the answer is actually correct or just garbage. When passed 0.025 (as a double) it prints out:
0.025000000000000001387778780781445675529539585113525390625
#define MAX_NUM_STR_LEN 128
void File_WriteNumber(File *fp, double value) {
char numbuf[MAX_NUM_STR_LEN];
int sz = sprintf(numbuf, "%.100g", value);
fwrite (numbuf , sizeof(char), sz, fp);
}