I'm looking for the fastest C++ routine to convert this double into a string.
The number must be rounded to 2 decimal places, no trailing zeros, no spaces.
For reasonably small numbers (up to about six digits or so before the decimal point), std::numeric_limits<double>::is_iec559 == true (it is usually true):
JLBorges, if I change the precision from 100 to 1000 and setprecision(3), then " if( lv%1000 == 0 ) return std::to_string( lv/1000 );" never execute and I have trailing zeros.
What should I change in order to get any precision I need (up to 8 decimal digits) without trailing zeros?
> if I change the precision from 100 to 1000 and setprecision(3),
> then " if( lv%1000 == 0 ) return std::to_string( lv/1000 );" never execute and I have trailing zeros.
I'm not able to reproduce that behaviour.
> What should I change in order to get any precision I need (up to 8 decimal digits) without trailing zeros?
> if I change the precision from 100 to 1000 and setprecision(3),
> then " if( lv%1000 == 0 ) return std::to_string( lv/1000 );" never execute and I have trailing zeros.
I'm not able to reproduce that behaviour.
> What should I change in order to get any precision I need (up to 8 decimal digits) without trailing zeros?