[Qt-creator] Qt-creator Digest, Vol 22, Issue 18
王成文
wang_chengwen at foxmail.com
Sun Jul 11 14:13:57 CEST 2010
来信收到,谢谢!
---原始邮件---
From:"qt-creator-request"<qt-creator-request at trolltech.com>;
Date:2010年7月11日(星期天) 晚上6:00
To:"qt-creator"<qt-creator at trolltech.com>;
Subject:Qt-creator Digest, Vol 22, Issue 18
Send Qt-creator mailing list submissions to
qt-creator at trolltech.com
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.trolltech.com/mailman/listinfo/qt-creator
or, via email, send a message with subject or body 'help' to
qt-creator-request at trolltech.com
You can reach the person managing the list at
qt-creator-owner at trolltech.com
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Qt-creator digest..."
Today's Topics:
1. tofloat() function gives inappropriate results (Ashish Vats)
2. Re: tofloat() function gives inappropriate results (David Dibben)
3. Re: tofloat() function gives inappropriate results (Andre Poenitz)
4. Nokia SDK and State Machine Framework on linux
(Antonio Cano G?mez)
5. Re: Nokia SDK and State Machine Framework on linux (Alex T.)
----------------------------------------------------------------------
Message: 1
Date: Sat, 10 Jul 2010 16:28:23 +0530
From: "Ashish Vats" <vatsa at lntebg.com>
Subject: [Qt-creator] tofloat() function gives inappropriate results
To: <qt-creator at trolltech.com>
Message-ID: <4C389FA7.883D.0036.0 at LNTEBG.com>
Content-Type: text/plain; charset="us-ascii"
I am using QT4.5 , I want to convert the string value to float so I have used function tofloat(). But the results i am getting are not accurate.
For example : If the string value is 7.6 then the output of function to float is 7.5999...
Regards
Ashish
Larsen & Toubro Limited
Electrical & Electronics Division - EBG
http://www.LNTEBG.com
This E-mail may contain confidential or privileged information for the intended recipient(s). If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.trolltech.com/pipermail/qt-creator/attachments/20100710/8f1e86fc/attachment-0001.html
------------------------------
Message: 2
Date: Sat, 10 Jul 2010 21:46:00 +0900
From: David Dibben <dibben at ieee.org>
Subject: Re: [Qt-creator] tofloat() function gives inappropriate
results
To: qt-creator at trolltech.com
Message-ID: <4C386B88.3020509 at ieee.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Hi Ashish,
On 10/07/2010 19:58, Ashish Vats wrote:
> I am using QT4.5 , I want to convert the string value to float so I have
> used function tofloat(). But the results i am getting are not accurate.
> For example : If the string value is 7.6 then the output of function to
> float is 7.5999...
Firstly, I am think this might not be the right list for this question.
I would try Qt-Interest instead.
But to answer your question. The problem is not with QString::toFloat
but the nature of floating point numbers. A float cannot represent 7.6
exactly, so you will always get this type of error
For example, try this little program:
int main()
?
??? float x = 7.6f;
printf(" %16.15f \n", x);
double y = 7.6;
printf(" %16.15f \n", y);
reurn 0;
?
This does not use Qt's QString at all, and I get:
7.599999904632568
7.600000000000000
When using a float, you won't get 7.6. I would try using a double
instead. That will give a better representation, but there will still be
strings that do not get converted exactly. Depending on what you want to
do with the numbers that may or may not matter.
--
David Dibben
Web: http://www.daviddibben.com
Mail: dibben at ieee.org
------------------------------
Message: 3
Date: Sat, 10 Jul 2010 15:37:41 +0200
From: Andre Poenitz <andre.poenitz at mathematik.tu-chemnitz.de>
Subject: Re: [Qt-creator] tofloat() function gives inappropriate
results
To: qt-creator at trolltech.com
Message-ID: <20100710133741.GA2217 at localhost>
Content-Type: text/plain; charset=us-ascii
On Sat, Jul 10, 2010 at 04:28:23PM +0530, Ashish Vats wrote:
> I am using QT4.5 , I want to convert the string value to float so I
> have used function tofloat(). But the results i am getting are not
> accurate.
This has nothing to do with Qt Creator, not even wit Qt and only
marginally with C++, it's just the way floating point numbers work.
> For example : If the string value is 7.6 then the output of function
> to float is 7.5999...
The value 7.6 has no finite representation in base 2. It's something
like 111.1001100110011... with the 0011 part repeating infinitely.
Whenever you try to store that form in some finite memory it needs to be
rounded or cut off at some point. So the value stored is _not_ 7.6 but
something close to it, and there is no way to reconstruct the original
value, as the cut-off part is permanently lost.
There are several approaches to avoid this "loss" (like using fixed
point arithmetic, rounding, or not converting to floating point at all).
Andre'
------------------------------
Message: 4
Date: Sun, 11 Jul 2010 08:12:59 +0200
From: Antonio Cano G?mez <antonio.cano.gomez at ovi.com>
Subject: [Qt-creator] Nokia SDK and State Machine Framework on linux
To: qt-creator at trolltech.com
Message-ID: <1278828779.1543.8.camel at Nokia-N900>
Content-Type: text/plain; charset="utf-8"
Hi,
I downloaded the Nokia SDK for linux 64 and tried to compile an aplication for symbyan.
This application compiled correctly for Nokia SDK in Windows.
But when I try to compile the same source code for Nokia SDK in Linux, I receive the error that the library for the state machine is not available.
Please, could someone tell me if there is to way to include this library or when it is going to be offivially available for linux version.
Thanks,
Toni
--------------------------------------------------------------
Ovi Mail: Making email access easy
http://mail.ovi.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.trolltech.com/pipermail/qt-creator/attachments/20100711/05144302/attachment-0001.html
------------------------------
Message: 5
Date: Sun, 11 Jul 2010 09:47:12 +0300
From: "Alex T." <dioxinu at gmail.com>
Subject: Re: [Qt-creator] Nokia SDK and State Machine Framework on
linux
To: qt-creator at trolltech.com
Message-ID:
<AANLkTinAovbmcyVtKHF1Im5YXtSfaEL1h_9tGKz4iKlZ at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Who is giving you an error? A compiler or linker? This library is in QtCore.
Probably you have to check your CFLAGS/CXXFLAGS and/or LDFLAGS.
2010/7/11 Antonio Cano G?mez <antonio.cano.gomez at ovi.com>
> Hi,
>
> I downloaded the Nokia SDK for linux 64 and tried to compile an aplication
> for symbyan.
>
> This application compiled correctly for Nokia SDK in Windows.
>
> But when I try to compile the same source code for Nokia SDK in Linux, I
> receive the error that the library for the state machine is not available.
>
> Please, could someone tell me if there is to way to include this library or
> when it is going to be offivially available for linux version.
>
> Thanks,
>
> Toni
>
>
> -------------------------------------------------------------- Ovi Mail:
> Making email access easy
> http://mail.ovi.com
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-creator
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.trolltech.com/pipermail/qt-creator/attachments/20100711/0f4f4444/attachment-0001.html
------------------------------
_______________________________________________
Qt-creator mailing list
Qt-creator at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-creator
End of Qt-creator Digest, Vol 22, Issue 18
******************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20100711/890b9c41/attachment.html
More information about the Qt-creator-old
mailing list