Results 1 to 2 of 2

Thread: Reason for divideEps in qwt

  1. #1
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Reason for divideEps in qwt

    Hi,

    I was wondering about QwtScaleArithmetic::divideEps method (and all other *-Eps-methods), like in the code below:

    Qt Code:
    1. static const double _eps = 1.0e-6;
    2.  
    3. double QwtScaleArithmetic::divideEps( double intervalSize, double numSteps )
    4. {
    5. if ( numSteps == 0.0 || intervalSize == 0.0 )
    6. return 0.0;
    7.  
    8. return ( intervalSize - ( _eps * intervalSize ) ) / numSteps;
    9. }
    To copy to clipboard, switch view to plain text mode 

    What is the reason for subtracting a scaled epsilon before dividing? I assume it has something to do with rounding, rounding errors, or the imprecision of floating point math. Maybe someone can give an example were this actually matters?
    Or is this code used for a totally different reason?

    Best regards.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Reason for divideEps in qwt

    What is the reason for subtracting a scaled epsilon before dividing? I assume it has something to do with rounding, rounding errors, or the imprecision of floating point math.
    Yes exactly this.

    Uwe

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

    IThu8uu1 (14th August 2013)

Similar Threads

  1. Replies: 2
    Last Post: 26th February 2011, 15:25
  2. segmentation fault for no apparent reason
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 12th February 2009, 11:13
  3. Synchronous Http (Good reason)
    By umbrella in forum Qt Programming
    Replies: 5
    Last Post: 4th April 2008, 14:14
  4. Replies: 4
    Last Post: 8th July 2007, 14:26
  5. Any reason for memory leak?
    By steg90 in forum Newbie
    Replies: 2
    Last Post: 10th May 2007, 15:00

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.