toString

@trusted pure nothrow
string
toString
(
const double value
,
in uint digitCount = 30
)

Return Value

Type: string

value as a string.

Examples

assert(0.0.toString(1) == `0`);
assert(0.1.toString(2) == `0.1`);

assert((-1.0).toString(1) == `-1`);
assert((-1.0).toString(2) == `-1`);
assert((-1.0).toString(3) == `-1`);

assert(3.14.toString(3) == `3.14`);
assert(3.141.toString(1) == `3`);
assert(3.141.toString(2) == `3.1`);
assert(3.141.toString(3) == `3.14`);
assert(3.141.toString(4) == `3.141`);
assert(3.141.toString(5) == `3.141`);

assert(1234567.123456789123456789.toString(7) == `1234567`);
assert(1234567.123456789123456789.toString(8) == `1234567.1`);
assert(1234567.123456789123456789.toString(9) == `1234567.12`);
assert(1234567.123456789123456789.toString(20) == `1234567.1234567892`);

Meta