Accuracy of floats saved with writedlm

Following the discussion on More control over writedlm formatting I understood that the tool to save numeric matrices was wrtiedlm. I have a bunch of small Matrix{Float64}s (some times just 1x2, sometimes ~500x3, never more) that I need to save.
In DelimitedFiles’s documentation it’s mentioned that “the source can be a text file, stream or byte array”.
My question is: since I’m saving floats (and not integers), in order to increase accuracy or decrease format-dependent rounding, should I be saving my matrices as a “byte array” instead of a “text file”? And if so, how exactly? All I know of is:

writedlm("tmp.csv", rand(3))

I’ll just close with that after some experimentation, the numbers saved had a whopping 18 digits to them, so I think I’m good…

1 Like

If you are saving them for later use in Julia, consider using JLD2.jl

1 Like

No, it needs to be universal forever.

When writing a .csv file with writedlm, a string representation of whatever you’re writing is saved instead of the binary representation. If the files are not meant to be read by humans, consider using a package with saving binary representation instead.

You would not gain any accuracy. There shouldn’t be any rounding.

2 Likes

This is very comforting, thank you. While

I feel writedlm is straightforward and fast. Seems like it’ll do the trick.

1 Like