Printing Double into String without exponential notation?


#1

Maybe I misunderstand the documentation, but I can’t avoid exponential notation with the way it’s in the doc?

String::String(double doubleValue, int numberOfDecimalPlaces )

using it this way: String(number,18)
will still give me strings like this: 4.1889975317955076e-06
although based on the documentation If I use ‘numberOfDecimalPlaces > 0’ then I won’t get exponential notation… And that’s exactly what I try to do.

Any thoughts on it would be much appreciated!


#2

Until someone of the JUCE team looks into this, I suggest you to use String::formatted(), which uses printf() formatting and I’m fairly sure it allows to print any decimal number without exponential notation (but I don’t remember which is the correct tag, you should check it yourself in the doc for printf())


#3

Yeah that’s a good idea, thanks! Still it would worth to correct the doc or the code :slight_smile: