Closed krauthaufen closed 4 years ago
Whats the reason to use Equals
instead of ==
on basic value types like float and double?
Why not use the ==
operator for our primitives?
From my point using the operator is more convenient and natural.
the actual reason is that double.NaN.Equals(double.NaN) => true
but double.NaN == double.NaN => false
Right... for a moment I had something like this in mind. This important information is completely missing here: https://docs.microsoft.com/en-us/dotnet/api/system.single.equals?view=netframework-4.8 Yes, I would assume in most cases it makes more sense to treat NaN as "Equal", like when you put a Ray in a dictionary.
For reasons to make the code more pleasing in the Equal methods, using Equals is reasonable. We definitely need to avoid boxing/unboxing and AggressiveInline most of them.
Nice!
We recently introduced a lot of boxing/unboxing/type-tests in https://github.com/aardvark-platform/aardvark.base/commit/d28b601cca83046ef08452409dea6f5f3fb238c5 which should be resolved by adding concrete Equals overloads for primitive types in my opinion... Thoughts?