Results 1 to 6 of 6

Thread: turn scientific to fixed

  1. #1
    Join Date
    Aug 2014
    Posts
    28
    Thanks
    15
    Qt products
    Qt5
    Platforms
    Windows

    Unhappy turn scientific to fixed

    hi all
    ok this is my code
    Qt Code:
    1. void MainWindow::on_pushButton_2_clicked()
    2. {
    3. float x,y,z;
    4. x=ui->lineEdit_3->text().toLong();
    5. y=ui->lineEdit_4->text().toLong();
    6. z=x*y;
    7. z=(float)z/100;
    8. cout<<fixed;
    9. ui->textBrowser_2->setText(b.setNum(z));
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 
    i dont know why still show me scientific format in textBrowser?!?
    any help will be grateful.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: turn scientific to fixed

    Try:
    Qt Code:
    1. ui->textBrowser_2->setText(b.setNum(x*y, 'f'));
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    ramin.lich (18th November 2014)

  4. #3
    Join Date
    Aug 2014
    Posts
    28
    Thanks
    15
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: turn scientific to fixed

    thank you so much.
    can you also tell me how can i remove float point for example my output is : 500000.000000
    in fact my answer is 5000 and 2 zero before point and 6 zero after point is surplus.
    thx.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: turn scientific to fixed

    Divide by 100 and floor or round to int.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    ramin.lich (18th November 2014)

  7. #5
    Join Date
    Aug 2014
    Posts
    28
    Thanks
    15
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: turn scientific to fixed

    Thanks again.
    i used this but has no effect. ( i mean floor has no effect. divide 100 will makes it better )
    Qt Code:
    1. b.setNum(floor(x*y/100),'f');
    To copy to clipboard, switch view to plain text mode 
    whats wrong?
    Last edited by ramin.lich; 18th November 2014 at 17:23.

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: turn scientific to fixed

    How do you know it has no effect? floor() converts a real value to an integer value so as a result you are getting an integer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    ramin.lich (19th November 2014)

Similar Threads

  1. Avoid scientific format for axis
    By qt_developer in forum Qwt
    Replies: 1
    Last Post: 9th June 2014, 20:42
  2. Need help in design scientific calculator
    By keyurparekh in forum Newbie
    Replies: 4
    Last Post: 11th March 2011, 23:00
  3. Replies: 3
    Last Post: 17th April 2010, 21:35
  4. qdoublespinbox with scientific notation
    By pospiech in forum Qt Programming
    Replies: 13
    Last Post: 3rd January 2009, 14:50
  5. My scientific plot problem
    By baray98 in forum Qt Programming
    Replies: 2
    Last Post: 5th August 2007, 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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.