@ipazin, Yes overall 4.4’s behaviour has improved in this regard, but I don’t think all is quite what it might first appear.
I think we can probably all agree that the outcome of the following should be true
a=9
b=8
c=b+1
equals(a,c)
In KNIME 4.4 it is indeed true, but in KNIME 4.3.4 it is false, so here yes 4.4 is better.
But it is worth checking how the behaviour has changed…
How about these variations? What is the result of equals(a,c) in each of the following? Below each question I have shown the result from 4.4 and 4.3.4
Q1
a=9.0
b=8
c=b+1
equals(a,c)
KNIME 4.4 => false
KNIME 4.3.4=> true
Did the result of Q1 surprise you?
Q2
a=9.0
b=8.0
c=b+1
equals(a,c)
KNIME 4.4 => true
KNIME 4.3.4=> true
Q3
a=9
b=8.0
c=b+1
equals(a,c)
KNIME 4.4 => false
KNIME 4.3.4=> false
For completeness, the result from the original example I wrote above:
Q4
a=9
b=8
c=b+1
equals(a,c)
KNIME 4.4 => true
KNIME 4.3.4=> false
This demonstrates that the change in 4.4 is not the equals operator, but is actually the assignment of values from arithmetic operations.
The reason for the results is the values assigned to variables a and c in each of the examples.
Q1 a=9.0, c=9.0 (KNIME 4.3.4, so true), c=9 (KNIME 4.4, so false)
Q2 a=9.0, c=9.0 (both versions, so true)
Q3 a=9, c=9.0 (both versions, so false)
Q4 a=9, c=9.0 (KNIME 4.3.4, so false) c=9 (KNIME 4.4, so true)
What this shows is that KNIME 4.4 has adjusted its behaviour in favour of assigning Integer values, whereas for KNIME 4.3.4, it favoured creation of Doubles during arithmetic expressions. It is not the behaviour of the “equals” function that has changed.
We still need to be wary and careful of how we handle integers and doubles when it comes to testing equality… and we need to be aware that some behaviour has changed (improved, I think) when it comes to derived values, and as @bruno29a has indicated, judicious use of explicit toInt(), toLong() or toDouble() when testing equality of (what we believe to be) Integer, Long or Double values respectively, is probably the safest bet to ensure it works irrespective of KNIME version.