toString

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

Return Value

Type: string

value as a string.

Examples

1 assert(0.0.toString(1) == `0`);
2 assert(0.1.toString(2) == `0.1`);
3 
4 assert((-1.0).toString(1) == `-1`);
5 assert((-1.0).toString(2) == `-1`);
6 assert((-1.0).toString(3) == `-1`);
7 
8 assert(3.14.toString(3) == `3.14`);
9 assert(3.141.toString(1) == `3`);
10 assert(3.141.toString(2) == `3.1`);
11 assert(3.141.toString(3) == `3.14`);
12 assert(3.141.toString(4) == `3.141`);
13 assert(3.141.toString(5) == `3.141`);
14 
15 assert(1234567.123456789123456789.toString(7) == `1234567`);
16 assert(1234567.123456789123456789.toString(8) == `1234567.1`);
17 assert(1234567.123456789123456789.toString(9) == `1234567.12`);
18 assert(1234567.123456789123456789.toString(20) == `1234567.1234567892`);

Meta