×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Rounding float/qreal numbers

    How do you convert float/qreal values to integer, with rounding? Surely there's a QMath class or some such that I'm simply not finding.

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Rounding float/qreal numbers

    float f = 2.4;
    int i = (int)(f + 0.5);

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Rounding float/qreal numbers

    I was thinking more along the line of something like Java's Math.rint function.

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Rounding float/qreal numbers

    Quote Originally Posted by danhicksbyron View Post
    I was thinking more along the line of something like Java's Math.rint function.
    It's kind of stupid to prefer function call to sum and cast.

Similar Threads

  1. 5800 S60 5th Ed. - Numbers appearing briefly in top right of screen navigating menus
    By dascott1966 in forum General Development Questions
    Replies: 22
    Last Post: 2010-11-07, 11:44
  2. How to print pretty (float) numbers?
    By JOM in forum Symbian
    Replies: 2
    Last Post: 2009-03-12, 16:34
  3. Replies: 6
    Last Post: 2008-10-15, 07:44
  4. Support for international phone numbers
    By padlon in forum General Development Questions
    Replies: 3
    Last Post: 2005-05-04, 10:53
  5. Where are my numbers stored on pc?
    By jamesmills in forum General Development Questions
    Replies: 1
    Last Post: 2004-02-09, 02:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×