Pure double to string conversion
Per Nordlöw
per.nordlow at gmail.com
Tue May 1 21:24:41 UTC 2018
Is there a way to convert a `double` to a `string` in a `pure`
function?
I tried
@safe pure unittest
{
import std.conv : to;
const y = 3.14.to!string;
}
but it fails to compile as
`pure` function `foo.__unittest_L1_C12` cannot call impure
function `std.conv.to!string.to!double.to`
Have anybody wrapped the corresponding C solution via, snprintf
or gcvt in a high-level D wrapper?
Is assume `gcvt` is GNU only but that's ok with me. I assume
`gcvt` is faster than `snprintf` in this case.
More information about the Digitalmars-d-learn
mailing list