Why does file_append/strf write var/double as floats?
Quote
As the printf class of functions are variadic (denoted by the elipsis „…“ in the function signature) the default argument promotions take place. Finally the call printf("float = %f\n", f) will after promotion look like printf("float = %f\n", (double)f) and printf can safely assume that every %f, %g, and %e denotes a parameter of type double. https://blogs.fau.de/wittmann/2013/11/c-default-argument-promotions/
The %f format specifier for the printf/scanf class of functions denotes a variable of type float which consumes 32 bits. In the example above d is of type double which uses 64 bits and actually requires %lf. The provided argument d (64 bits) would be interpreted as a variable of type float (32 bits). https://blogs.fau.de/wittmann/2013/11/c-default-argument-promotions/
%lf does not exist in clite or does it?
Quote
Rounding errors occur when a number can’t be stored precisely. This can happen even with simple numbers, like 0.1. Therefore, rounding errors can, and do, happen all the time. A corollary of this rule is: never use floating point numbers for financial or currency data. https://www.learncpp.com/cpp-tutorial/floating-point-numbers
I'm clearly missing something here and i don't get it...