Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.1
-
None
Description
Dear all,
I am reading strings representing floats and converting them to float using QString()::toFloat().
I noticed that on some inputs, this conversion fails (but toDouble() succeeds).
Example:
String: "-3.4028235e+038" (equivalent to 0xFFFF7FFF as LE-4byte float)
Reading this with toFloat(&ok) fails (ok = false), using toDouble(&ok) works as expected.
Interestingly, Qt can not parse its own output when using this float, converting it to QString using QString::number(f, 'g', 8) and trying to parse this QString again with toFloat().
You can find a minimal example attached. Cases A and B show the conversion using toFloat() failing, cases C and D show the conversion of the same numbers succeed with toDouble().