On Saturday, 15 December 2012 at 19:01:23 UTC, ref2401 wrote:
What does means 'maxRelDiff' parameter?
I looked at the source code of this method and I still didn't get it.

return fabs((lhs - rhs) / rhs) <= maxRelDiff
|| maxAbsDiff != 0 && fabs(lhs - rhs) <= maxAbsDiff;

In what cases can I use this parameter?


basically floating point types are not accuracy. Is 0.000001 = 0.00000000000000000000000000000001?

It all depends! floating point calculations can accumulate rounding errors which result in comparisons that should be valid are not.

Hence, it is not technically correct to compare two floating point types. Hence, the calculation above simply compares how close the two are and accepts them as == if they are within some distance of each other.

Reply via email to