[Qt-interest] SQL (ODBC) retreiving doubles incorrectly
André Somers
andre at familiesomers.nl
Sat Oct 3 09:55:55 CEST 2009
Thanks,
But no, this won't work.
Say I have a number like 0.00432 in my database. In my query, this will turn
up as E-3, instead of 4.32E-3. Prepending E-3 with 1.0 doesn't yield me
0.00432. What I am doing now is first changing 0.00432 to 432.0 by
multiplying the value in SQL, which does arrive properly. Then after reading
the value from the query, I divide again and get my 0.00432 back. One
problem is that this limits my precision. This works for 4.32E-3, and even
4.32E-5, but not for E-6 or E-10. I *do* want to be able to read those, even
if it is not so urgent at the moment.
André
-----Oorspronkelijk bericht-----
Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Julien Cugnière
Verzonden: vrijdag 2 oktober 2009 15:58
Aan: Qt-interest
Onderwerp: Re: [Qt-interest] SQL (ODBC) retreiving doubles incorrectly
2009/10/2 Andre Somers <andre at familiesomers.nl>:
> Julien Cugnière wrote:
>> A slightly better hack would be to prepend "0.0" to the value you get
>> if it starts with 'E' or 'e'. Then you can use QString::toDouble().
>>
> I disagree. My hack actually gets the value I was after, instead of
> returning 0. Only if the value is smaller than 0.000001, I will still
> get 0. That is not a big issue. It remains a very ugly hack nontheless.
Sorry, I wasn't thinking properly : I should have said prepend "1",
and not "0.0".
The idea is to turn the string "E-3" into "1E-3", which can be
converted to a double, and gives you the correct value (unless I'm
still not thinking properly :-)
--
Julien Cugnière
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list