Most performant way of converting int to string

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 22 14:36:16 PST 2015


On 12/22/2015 10:15 AM, Andrew Chapman wrote:
 > On Tuesday, 22 December 2015 at 18:11:24 UTC, rumbu wrote:

 >> Converting numbers to string involves the most expensive known two
 >> operations : division and modulus by 10.
 >
 > Cool thanks, so essentially it's unavoidable

There is hope. :)

 > I have a background in PHP programming where we don't really get 
exposed to
 > memory allocation, conversions etc.

You will love Andrei's recently-released presentations from code::dive 
in November 2015:

   Writing Fast Code I: https://www.youtube.com/watch?v=ph7FP0LnmcA

   Writing Fast Code II: https://www.youtube.com/watch?v=3_FXy3cT5C8

   Three Cool Things about D: https://youtube.com/watch?v=FdpaBHyQNco

The first one has an example of optimizing uint64ToAscii() at around 
1:16:30:

 
https://www.youtube.com/watch?feature=player_detailpage&v=ph7FP0LnmcA#t=4604

Ali



More information about the Digitalmars-d-learn mailing list