View source code Display the source code in std/bigint.d from which this page was generated on github. 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. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.bigint.BigInt.toString

Convert the BigInt to string, passing it to the given sink.

Prototypes

void toString(
  void delegate(const(char)[]) sink,
  string formatString
) const;

void toString(
  void delegate(const(char)[]) sink,
  std.format.FormatSpec!(char) f
) const;

Parameters

NameDescription
sink A delegate for accepting possibly piecewise segments of the formatted string.
formatString A format string specifying the output format.
Available output formats:
"d" Decimal
"x" Hexadecimal

Example

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

import std.format : format;

auto x = BigInt("1_000_000");
x *= 12345;

assert(format("%d", x) == "12345000000");
assert(format("%X", x) == "2_DFD1C040");


Authors

Don Clugston

License

Boost License 1.0.

Comments