Skip to content

TextString

Converts an expression to a plain text string (similar to ToString but aimed at human-readable output).

$ wo 'TextString[3.14]'
3.14

An approximate real is always written in full decimal — never the *^ notation ToString switches to — and keeps a fractional digit while its integer part is shorter than six digits:

$ wo 'TextString[1234567.]'
1234567.
$ wo 'TextString[2.]'
2.0

An exact number that is not a bare symbol is numericized to six significant digits, while a symbol prints as itself:

$ wo 'TextString[1/3]'
0.333333
$ wo 'TextString[Sqrt[2]]'
1.41421
$ wo 'TextString[Pi]'
Pi

The rules apply element-wise inside a list or association:

$ wo 'TextString[{1/2, Pi}]'
{0.5, Pi}

A complex number shows both parts, the imaginary one always as a real:

$ wo 'TextString[2 + 3 I]'
2 + 3.0i

A missing value contributes nothing to the text:

$ wo 'TextString[{Missing["x"], 1}]'
{, 1}