1. 12
  1.  

  2. 3

    Ulf Adams recently (2018) shown outstanding algorithm Ryu[1] that converts a floating point number to its shortest decimal representation. It’s currently the fastest known float-to-string conversion algorithm.

    Stephan T. Lavavej showed at CppCon 2019[2] how he implemented <charconv> in msvc’s stl lib using that algorithm.

    [1] https://github.com/ulfjack/ryu [2] https://www.youtube.com/watch?v=4P_kbF0EbZM

    1. 1

      I am not home now, but I comment so I can remember to test it when I get there.

      I believe just by switching the stringstream for a direct access you will get much faster times.

      1. 2

        Probably std::stoi would be faster you mean? But you have to loop that right?