Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
5.10.1
-
None
Description
The QVariant in which a float is stored is able to produce its string representation with too much decimal digits with the method toString().
Consider following float: -10795.0684
The following string is generated: -10795.068359375
While this is in fact correct, it's unnecessary information and it causes e.g. Validator on float expecting just 7 decimal digits to fail.
The bug is on the qvariant.cpp - line 433 which sends the float into the QString conversion method: *str = QString::number(d->data.f, 'g', QLocale::FloatingPointShortest);
With double decimal digits requested. The float is converted here to double and hence it gains additional precision!
Instead std::numeric_limits<float>::digits should be used there.
Attachments
Issue Links
- is duplicated by
-
QTBUG-80429 Less digits from QVariant::toString() for float and double values
- Closed