Files
lix/lix/libexpr/builtins/toString.md
T
Tom Hubrecht a5e2376350 documentation: Explain how a float will be transformed into a string
`prim_toString` uses `state.coerceToString`, which in turns defers to
`std::to_string` for floats, which 'Converts a floating point value to a
string as if by std::sprintf(buf, "%f", value)'.
Finally, the `%f` specifier 'Converts floating-point number to the
decimal notation in the style [-]ddd.ddd. Precision specifies the exact
number of digits to appear after the decimal point character. The
default precision is 6.'

Closes #747

Change-Id: I42339651005d20f272459cf9f80b274f2076b1e3
2025-03-18 13:42:25 +01:00

681 B

name, args, renameInGlobalScope
name args renameInGlobalScope
toString
e
false

Convert the expression e to a string. e can be:

  • A string (in which case the string is returned unmodified).

  • A path (e.g., toString /foo/bar yields "/foo/bar".

  • A set containing { __toString = self: ...; } or { outPath = ...; }.

  • An integer.

  • A floating-point value, it will be converted to the decimal notation in the style [-]ddd.ddd with 6 digits appearing after the decimal point.

  • A list, in which case the string representations of its elements are joined with spaces.

  • A Boolean (false yields "", true yields "1").

  • null, which yields the empty string.