Sprint/writedlm digit precision

Hi,

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]," ")

or

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.precision(13);
  std::cout << m  << std::endl;

(setprecision - C++ Reference)

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

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