Chris Rackauckas
Chris Rackauckas

Reputation: 19152

Creating strings of full precision arrays

I am creating a logging function and need to create a string for the values of a bunch of arrays at some intermediate points (to both print and save to a file). I was using the following to save the arrays Ai, Bi, α, and βi:

resString = """
  A₀ = $A0
  A₁ = $A1
  B₀ = $B0
  B₁ = $B1
  α  = $α
  β₁ = $β1
  β₂ = $β2
  β₃ = $β3
  β₄ = $β4
  """

but interpolation doesn't give you the full precision and I need to save the arrays at full precision. Is there an easy way to modify this so that way all of the strings show the full values for the numbers?

Upvotes: 5

Views: 88

Answers (1)

Alexander Morley
Alexander Morley

Reputation: 4181

Is this what you want?

join(string.(A0), ",")

or

"[$(join(string.(A0), ","))]" if you need the square brackets too.

If you have a look here (julia/base/strings/string.jl) you can probably work out why!

Upvotes: 5

Related Questions