[Qt-interest] string to float

Yves Bailly yves.bailly at sescoi.fr
Wed Jan 27 10:17:14 CET 2010


Le 27/01/2010 09:55, yanqzhi at gmail.com a écrit :
> 
> 
> hi,
> 
> When a string converts to a float, the float returned does't exactly 
> match the string;
> 
> QString str("57.130");
> float a = str.toFloat();
> 
> the float is 57.130001.

That's probably because "57.130" can't be represented as a float.
Some hints: http://en.wikipedia.org/wiki/IEEE_754-2008

Hope this helps.

-- 
     /- Yves Bailly - Software developper  -\
     \- Sescoi R&D  - http://www.sescoi.fr -/
"The possible is done. The impossible is being done. For miracles,
thanks to allow a little delay."




More information about the Qt-interest-old mailing list