I'm afraid that's the crucial question you need to ask and answer yourself first – if those two numbers should appear as a single element as your Set element / Dictionary key – then you are not right trying using them as is as Set elements / Dictionary keys.
You can probably group struct elements together in a "substruct" to keep your EQ / hash implementation short and less error prone. I am not aware of a way to call through the original implementation, pseudocode:
@available(*, deprecated, message:)
static func == (lhs: Self, rhs: Self) -> Bool {
super . ==(lhs, rhs) // no such thing
}
Wouldn't hashing those values be just as invalid as trying to compare with ==?
If the key you save into your dict is 5.4999999999999991118215802999, but you later look for 5.5000000000000008881784197001, you won't find it*.
* Unless it just happens to have a hash collision and map into the same bucket.
I strongly suspect that you want a tree-based dictionary instead of a hash-map based one. It's logarithmic look-up compared to constant-time, but it can correctly answer the question: "What's the closest stored key to 5.5000000000000008881784197001?"
Direct access to dictionary is not possible, and for comparison as I wrote we use isAlmostEqual func. Also such close values can not coexist in one Dictionary, so the correct value will be found.
For now we use NonEmpty<OrderedDictionary>, thanks for pointing this out. I will check TreeDictionary.