I'm trying to merge list member with the same numerical key values:
a = {53.8 -> x, Floor[53.81`, 0.2] -> y};
Merge[a, Total]
then I get:
<|53.8 -> x, 53.8 -> y|>
So I check the output of Floor
:
Floor[53.81`, 0.2] // FullForm
53.800000000000004`
I paste it into the expression to test their equality:
a = {53.8 -> x, 53.800000000000004` -> y};
a[[1, 1]] == a[[2, 1]]
Merge[a, Total]
True
<|53.8 -> x, 53.8 -> y|>
but when I insert one more zero into 53.800000000000004`:
a = {53.8 -> x, 53.8000000000000004` -> y};
a[[1, 1]] == a[[2, 1]]
Merge[a, Total]
True
<|53.8 -> x + y|>
- Seeing the long digits of
FullForm
, am I usingFloor
in the correct way? - Does
Merge
use different number precision than other evaluations?
Floor[53.81, 1/5]
gives269/5
. You can use this as a normalizing function and apply it to all keys before merging. $\endgroup$