E
E
Eugene Ordinary2017-01-16 20:58:28
C++ / C#
Eugene Ordinary, 2017-01-16 20:58:28

How to convert float to string with formatting?

The to_string function always leaves 6 decimal places, including unnecessary zeros.
How to drop zeros at the end? For example, to display 1.0147 instead of 1.014700.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Zhilin, 2017-01-16
@Anton3

You can use std::stringstream. But it is better to include the fmt library.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question