I have an array of values like [0.75, 0.0050000000000000001, 0.0050000000000000001, 0.0050000000000000001, 0.0050000000000000001, 0.0050000000000000001, 0.004000000000
Your problem strongly suggests you're using the wrong type for your data. Rather than trying to fix it up at the point of uniquing, I suspect you really just want to modify your model so the issue doesn't occur.
If you want to do decimal-based math, you should use decimal-based numbers, like NSDecimalNumber. For example, considering the case where you do have doubles coming into the system, you can convert them to NSDecimalNumber with a "0.001 accuracy" this way:
let values = [0.75, 0.0050000000000000001, 0.0050000000000000001, 0.0050000000000000001, 0.0050000000000000001, 0.0050000000000000001, 0.0040000000000000001]
let behavior = NSDecimalNumberHandler(roundingMode: .plain,
scale: 3,
raiseOnExactness: false,
raiseOnOverflow: false,
raiseOnUnderflow: false,
raiseOnDivideByZero: false)
let decimalNumbers = values.map {
NSDecimalNumber(value: $0).rounding(accordingToBehavior: behavior)
}
let uniqueDecimals = Set(decimalNumbers)
Once you are working with NSDecimalNumber, and applying the appropriate rounding rules, then most operations work as you expect. You can just put them into a Set to unique them. You can check for equality. You can print them, and they will behave like decimal numbers. Make your model match your meaning, and most other problems disappear.