Int128.toString

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

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

Parameters

sink Writer

Output range to write to.

fmt FormatSpec

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'.

Examples

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

import std.format : format;

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

Also can format as wchar or dchar.

import std.conv : to;

assert(to!wstring(Int128.max) == "170141183460469231731687303715884105727"w);
assert(to!dstring(Int128.max) == "170141183460469231731687303715884105727"d);

See Also

Meta