auto c = complex(1.2, 3.4); // Vanilla toString formatting: assert(c.toString() == "1.2+3.4i"); // Formatting with std.string.format specs: the precision and width // specifiers apply to both the real and imaginary parts of the // complex number. import std.format : format; assert(format("%.2f", c) == "1.20+3.40i"); assert(format("%4.1f", c) == " 1.2+ 3.4i");
Converts the complex number to a string representation.
The second form of this function is usually not called directly; instead, it is used via std.string.format, as shown in the examples below. Supported format characters are 'e', 'f', 'g', 'a', and 's'.
See the std.format and std.string.format documentation for more information.