I have an array or matrix that I want to print, but only to three digits of precision. How do I do that. I tried the following.
> @printf("%.3f", rand())
0.742
> @printf("%.3f", rand(3))
LoadError: TypeError: non-boolean (Array{Bool,1}) used in boolean context
while loading In[13], in expression starting on line 1
Update: Ideally, I just want to call a function like printx("{.3f}", rand(m, n))
without having to further process my array or matrix.
How about this?
I would do it this way:
I don't think @printf accepts a list of arguments as you might be expecting.
One solution you could try it to use @sprintf to create formatted strings, but collect them up in a list comprehension. You might then use join to concatenate them together like so:
The OP said:
This answer to a similar questions suggests something like this: