Defining your own epsilon - as you have done before - is the correct thing to do.
The "double epsilon" defined in various languages and frameworks is not an intended as some "margin of error" for performing comparisons - it's just the smallest possible increment you could ever represent with the number type.
Because we are talking about floating point numbers (not fixed scale/precision numbers), the level of precision specified by Number.Epsilon is only possible when you are storing a very small number - otherwise the precision will change depending on the number you store.
See my wordy reply to the original article ( dev.to/alldanielscott/comment/b46f ) for why the code recommended in the article here is not safe!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Defining your own epsilon - as you have done before - is the correct thing to do.
The "double epsilon" defined in various languages and frameworks is not an intended as some "margin of error" for performing comparisons - it's just the smallest possible increment you could ever represent with the number type.
Because we are talking about floating point numbers (not fixed scale/precision numbers), the level of precision specified by Number.Epsilon is only possible when you are storing a very small number - otherwise the precision will change depending on the number you store.
See my wordy reply to the original article ( dev.to/alldanielscott/comment/b46f ) for why the code recommended in the article here is not safe!