View source code
Display the source code in std/int128.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.int128.Int128.toString

Formats Int128 with either %d, %x, %X, or %s (same as %d).

void toString(Writer, FormatSpec) (
  scope ref Writer sink,
  scope const ref FormatSpec fmt
) const;

Parameters

NameDescription
sink Output range to write to.
fmt A std.format.FormatSpec which controls how the number is displayed.

Throws

std.format.FormatException if the format specifier is not one of 'd', 'x', 'X', 's'.

See Also

std.format.formatValue

Example

toString is rarely directly invoked; the usual way of using it is via std.format.format:

import std.format : format;

writeln(format("%s", Int128.max)); // "170141183460469231731687303715884105727"
writeln(format("%s", Int128.min)); // "-170141183460469231731687303715884105728"
writeln(format("%x", Int128.max)); // "7fffffffffffffffffffffffffffffff"
writeln(format("%X", Int128.max)); // "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
writeln(format("%032X", Int128(123L))); // "0000000000000000000000000000007B"
writeln(format("%+ 40d", Int128(123L))); // "                                    +123"
writeln(format("%+-40d", Int128(123L))); // "+123                                    "

Example

Also can format as wchar or dchar.

import std.conv : to;

writeln(to!wstring(Int128.max)); // "170141183460469231731687303715884105727"w
writeln(to!dstring(Int128.max)); // "170141183460469231731687303715884105727"d

Authors

License

Boost License 1.0