Sprint/writedlm digit precision


Is there a simple why for me to set the number of digits when writing to a file?
I have something like:

using DelimitedFiles
writedlm ("$filename.xyz",[x y z]," ")


write(io, "xyz");print(io,"\r\n");
print(io,sprint(show,[x,y,z]));print(io," ");

In c++ you just set:

  std::cout.setf( std::ios::fixed, std:: ios::floatfield ); // floatfield set to fixed
  std::cout << m  << std::endl;


I am sure the answer is simple as always, I just cant spot it in the help.

I am also interested in the answer to this question. I use writedlm to save arrays of floats and I have never found a solution for printing rounded values that was not to create a rounded copy array.

that was not to create a rounded copy array

Agree. Still, it works.

writedlm ("$filename.xyz",round.([x y z],digits=5)," ")

(alternatively, sigdigits)

1 Like