Double Comparison produces inconsistent results

I am trying to compare numbers from two columns - both are are type Double. I am using Rule-based row filter to extract rows where Column1 value (Double) does not match with Column2 value (Double). While I get some rows where the values are truly different, however in many cases I can visually see values are the same across both columns but my rule based filter still extracts those rows as if those values differ.

Below is the Rule-based Row filter configuration
image

below is the result showing two column values match but still included

I also tried TaxDiff (last column) if value is 0 then exclude - but even then these rows are included. What am I missing here?

Hi @jaydeep2

It is usual usual that double comparisons using the “=” (equal) operator might be inconsistent. Doubles should only be compared using an equal operator if their number of decimals are first equally rounded.

To check that double values from different columns are exactly the same, rather try a subtraction and display the difference using the “Full Precision” rendering (right click on column name to get access to it):

image

Most probably the values differ by a tiny decimal value.

A solution to this problem is to use the -Math Formula (Multi Column)- node to round down to a given decimal the columns you need to compare before comparing them using the “=” operator.

Hope it helps.

Best
Ael

10 Likes

Learnt something new today about “double” precision. Thanks so much!

3 Likes

Hi @jaydeep2

Thank you for your kind message and for validating the answer! I’m glad it helped.

Best wishes,
Ael

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.