PDA

View Full Version : Reason for divideEps in qwt



IThu8uu1
13th August 2013, 17:45
Hi,

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



static const double _eps = 1.0e-6;

double QwtScaleArithmetic::divideEps( double intervalSize, double numSteps )
{
if ( numSteps == 0.0 || intervalSize == 0.0 )
return 0.0;

return ( intervalSize - ( _eps * intervalSize ) ) / numSteps;
}



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.

Uwe
14th August 2013, 15:30
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