float/String precision bug?


#1

15.90625f can be represented as a float, but String (15.90625f) gives "15.9062"

So the following will fail :

float a = 15.90625f;
String sa (a);
float b = sa.getFloatValue();

jassert (a == b);

#2

We’re consistent with the standard library.

std::cout << a << "\n";   // 15.9062

std::cout.precision (17);
std::cout << a << "\n";   // 15.90625

If you do

String sa (a, 17);

then you’ll get 15.90625f.