【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.1.16.1.6 is_equal
Contents
Description
Compare two double values and see if they are equal or not.
Syntax
BOOL is_equal( double x, double y, int nCode = '=' )
Parameters
- x
- [input] first compare value
- y
- [input] second compare value
- nCode
- [input] '=' for testing equality, '!' for testing inequality, any other value will return FALSE.
Return
Return true if equal when testing equality or unequal when testing inequality, else false.
Examples
EX1
void is_equal_ex1() { double a = 1.; // add 1.e-17: a += 1.e-17; // Compare with 1.: if (is_equal(a, 1.)) { // If @ND still has the default value, which is 1.e-16, this will be true. out_str("a is 1."); } else { out_str("a is not 1."); } // add 1.e-14 a += 1.e-14; if (is_equal(a, 1.)) { // If @ND still has the default value, which is 1.e-16, this will be false. out_str("a is 1."); } else { out_str("a is not 1."); } }
Remark
compare two double values and see if they are equal or not equal in the same sense as in LabTalk.
This function uses the LabTalk system variable @ND to test if (abs(x)-abs(y))/((abs(x)+abs(y)) is less then @ND or not. If @ND = 0, it does standard arithmetic comparison x == y.
See Also
Header to Include
origin.h