Most performant way of converting int to string

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at
Tue Dec 22 11:02:46 PST 2015

On 12/22/15 12:15 PM, Andrew Chapman wrote:
> Sorry if this is a silly question but is the to! method from the conv
> library the most efficient way of converting an integer value to a string?
> e.g.
> string s = to!string(100);
> I'm seeing a pretty dramatic slow down in my code when I use a
> conversion like this (when looped over 10 million iterations for
> benchmarking).
> Cheers!

Does it need to be string? What about a mutable char buffer?

If you are allocating and throwing away strings in a tight loop, simply 
reusing the buffer could save a ton of time.

Look into std.format


More information about the Digitalmars-d-learn mailing list