[Qt-interest] string to float

Ulf-Alexander v. Ceumern-Lindenstjerna ceumern at vrmagic.com
Wed Jan 27 10:01:10 CET 2010


Never test a float for equality...

http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm


> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of yanqzhi at gmail.com
> Sent: Wednesday, January 27, 2010 9:55 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] string to float
> 
> 
> 
> 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.
> 
> 
>         yanqzhi at gmail.com
>           2010-01-27




More information about the Qt-interest-old mailing list