Results 1 to 11 of 11

Thread: toDouble() and rounding problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    50
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default toDouble() and rounding problem

    Hello, guys. I`ve got a little problem
    I`m using QT4.4.0+VC++2008
    Database SQLite.
    I have 3 double columns in the database:
    1 = 100000.55
    2 = 10000.55
    3 = 1000.55

    I`m selecting those values and displaying in QLabel

    Qt Code:
    1. QSqlQuery query("SELECT * FROM main");
    2. double eur, usd, bgn;
    3. while (query.next()) {
    4. eur= query.value(1).toDouble();
    5. usd = query.value(2).toDouble();
    6. bgn= query.value(3).toDouble();
    7. }
    To copy to clipboard, switch view to plain text mode 

    but there goes the rounding problem:

    1st value goes 100001
    2nd value goes 10000.5
    3rd value goes 1000.55

    What am i missing and how to make 1st value to be shown as 100000.55
    I`ve got alot of calculations and that rounding is a problem. Thanx.

    PS. If i make it "eur= query.value(1).toString();" it shows the correct value but i need to do calculations and at some time i`ll call str.toDouble() and i get the round again.
    Last edited by sadjoker; 27th August 2008 at 15:01.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.