[test] CLOSE and CLOSE_FRACTION tolerance
I am trying to understand the tolerance value passed as the last parameter to the BOOST_XXX_CLOSE and BOOST_XXX_CLOSE_FRACTION macros. The doc says that for the former the value is percentage units while for the latter it is the fraction of absolute values being compared. But in each case there are two values, not just one. Which of the two values are used to determine the tolerance amount in each case ? If both values are being used in each case, how is the tolerance amount computed from the tolerance value passed ?
Edward Diener
I am trying to understand the tolerance value passed as the last parameter to the BOOST_XXX_CLOSE and BOOST_XXX_CLOSE_FRACTION macros. The doc says that for the former the value is percentage units while for the latter it is the fraction of absolute values being compared. But in each case there are two values, not just one. Which of the two values are used to determine the tolerance amount in each case ? If both values are being used in each case, how is the tolerance amount computed from the tolerance value passed ?
These are using strict check: |a-b|/|a| < tolerance and |a-b|/|b| < tolerance You can get weak check if you want (or instead of and above) by using close_at_tolerance predicate directly. Regards Gennadiy
On 6/3/2011 1:55 AM, Gennadiy Rozental wrote:
Edward Diener
writes: I am trying to understand the tolerance value passed as the last parameter to the BOOST_XXX_CLOSE and BOOST_XXX_CLOSE_FRACTION macros. The doc says that for the former the value is percentage units while for the latter it is the fraction of absolute values being compared. But in each case there are two values, not just one. Which of the two values are used to determine the tolerance amount in each case ? If both values are being used in each case, how is the tolerance amount computed from the tolerance value passed ?
These are using strict check:
|a-b|/|a|< tolerance and |a-b|/|b|< tolerance
You can get weak check if you want (or instead of and above) by using close_at_tolerance predicate directly.
As I understand your answer, the first case above above refers to CLOSE and the second case above to CLOSE_FRACTION. Can you add that to the docs of both so that everyone can better understand it ? Thanks !
On 6/3/2011 8:45 AM, Edward Diener wrote:
On 6/3/2011 1:55 AM, Gennadiy Rozental wrote:
Edward Diener
writes: I am trying to understand the tolerance value passed as the last parameter to the BOOST_XXX_CLOSE and BOOST_XXX_CLOSE_FRACTION macros. The doc says that for the former the value is percentage units while for the latter it is the fraction of absolute values being compared. But in each case there are two values, not just one. Which of the two values are used to determine the tolerance amount in each case ? If both values are being used in each case, how is the tolerance amount computed from the tolerance value passed ?
These are using strict check:
|a-b|/|a|< tolerance and |a-b|/|b|< tolerance
You can get weak check if you want (or instead of and above) by using close_at_tolerance predicate directly.
As I understand your answer, the first case above above refers to CLOSE and the second case above to CLOSE_FRACTION. Can you add that to the docs of both so that everyone can better understand it ? Thanks !
Or perhaps you mean that for both CLOSE and CLOSE_FRACTION both cases above are calculated ? In which case I still do not understand what is the difference between "percentage units" and "fraction of absolute value".
Edward Diener
These are using strict check:
|a-b|/|a|< tolerance and |a-b|/|b|< tolerance
Or perhaps you mean that for both CLOSE and CLOSE_FRACTION both cases above are calculated ? In which case I still do not understand what is the difference between "percentage units" and "fraction of absolute value".
Yes. Both tools use strict comparison. "tolerance" in above inequalities is measured in "fraction units". To get "percentage units" you need to multiply the tolerance by 100. Usually it's easier to think in "percentage units" form: a is different from b by x percent, but fraction tolerances are popular as well. Gennadiy
participants (2)
-
Edward Diener
-
Gennadiy Rozental