Replies: 1 comment 2 replies
-
Thus, on x86/x64, The difference here is one that moves closer towards determinsm by not allowing the operation to be considered commutative. A "correct" implementation would be one where we provide:
This would represent a non-trivial perf impact to Min/Max/Clamp by default. |
Beta Was this translation helpful? Give feedback.
-
Starting with .NET 5.0 the behavior of
Vector2/3/4.Clamp
changed. Consider the following code:Between .NET Framework 4.6 and .NET Core 3.1 this code prints the following:
But starting with .NET 5 both rows are zeros.
In the sources I can see that up to .NET Core 3.1 it worked like
Math.Min/Max
, preserving NaN values, and above it turned into an intrinsic method where the fallback implementation callsVector.Min/Max
(which btw are intrinsics as well).In fact I prefer the new behavior, even the documentation feels more correct when saying:
However, I don't see anything about this change in the docs and I'm not sure whether I can build on the current behavior. Is it something that depends on the actual intrinsics injected for the current CPU if possible, or is it guaranteed that now
Clamp
always returns values between the specified range?Beta Was this translation helpful? Give feedback.
All reactions