diff --git a/core/Float.cc b/core/Float.cc index ed0de6178bbf52fdbcdfaf1c0f4e9142949a4fae..e790b04795d913c1208128a6255e468b054d297d 100644 --- a/core/Float.cc +++ b/core/Float.cc @@ -1403,7 +1403,9 @@ double operator/(double double_value, const FLOAT& other_value) boolean operator==(double double_value, const FLOAT& other_value) { other_value.must_bound("Unbound right operand of float comparison."); - return double_value == other_value.float_value; + return double_value == other_value.float_value || // check if they're both NaN + (double_value != double_value && + other_value.float_value != other_value.float_value); } boolean operator<(double double_value, const FLOAT& other_value) diff --git a/regression_test/predefFunction/str_to_OK.ttcn b/regression_test/predefFunction/str_to_OK.ttcn index 82435c8d32fab823d95c4fd336a36d923f3380ba..6b445a886e7463fdc63dfaa571012dd95ded4f82 100644 --- a/regression_test/predefFunction/str_to_OK.ttcn +++ b/regression_test/predefFunction/str_to_OK.ttcn @@ -363,11 +363,22 @@ testcase str_to_float() runs on PDTestComponent{ //In testcase definition// {setverdict(pass);} else {setverdict(fail, __LINE__);} if ((s2fmp16 == str2float(s2fmp16_str)) + and (str2float(s2fmp16_str) == s2fmp16) and (s2fmp16 == not_a_number)) {setverdict(pass);} else {setverdict(fail, __LINE__);} } +testcase str_to_float_var_nan() runs on PDTestComponent { + var charstring vl_cs := "not_a_number"; + if(str2float(vl_cs) == not_a_number){ + setverdict(pass) + } else { + setverdict(fail,"expected not_a_number got:", str2float(vl_cs)); + } +} + + /*--- STR2HEX --------------------------------------------------*/ @@ -627,6 +638,7 @@ testcase str_to_oct() runs on PDTestComponent{ control { execute (str_to_bit()); execute (str_to_float()); + execute (str_to_float_var_nan()); execute (str_to_hex()); execute (str_to_int()); execute (str_to_oct());