Function fmt.Sprintf("%f", some_float_number) converts float to string with a default precision equal to 6:
The default precision for %e, %f and %#g is 6; for %g it is the smallest number of digits necessary to identify the value uniquely.
(source).
Changing format from "%f" to "%g" gives a precision necessary for saving floating point numbers without loss. According to the above documentation this precision is also a default option for converting floats to strings.
The current precision leads to the inconsistencies even when we only open and write a csv file again. Minimal working example:
Moreover the casting to string is used in the function Rapply. Because of that applying an identity function to a dataframe changes it. Minimal working example:
Function
fmt.Sprintf("%f", some_float_number)
converts float to string with a default precision equal to 6:The default precision for %e, %f and %#g is 6; for %g it is the smallest number of digits necessary to identify the value uniquely.
(source). Changing format from "%f" to "%g" gives a precision necessary for saving floating point numbers without loss. According to the above documentation this precision is also a default option for converting floats to strings.The current precision leads to the inconsistencies even when we only open and write a csv file again. Minimal working example:
Running a program:
with a csv file:
produces the output csv file:
Suggested change solves this issue.
Moreover the casting to string is used in the function Rapply. Because of that applying an identity function to a dataframe changes it. Minimal working example:
Running a program:
with a csv file:
prints only 6 digits:
This issue is solved as well by the suggested change.