-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
Description
Description
I'm getting incorrect results using Vector3.EqualsAny, or I'm using it wrong.
Here's a small test program:
using System.Numerics;
Vector3 v1 = new(1, 2, 3);
Vector3 v2 = new(4, 5, 6);
Console.WriteLine($"v1 = {v1}");
Console.WriteLine($"v2 = {v2}");
Console.WriteLine($"EqualsAny(v1, v2) = {Vector3.EqualsAny(v1, v2)}");
And here's the output:
v1 = <1, 2, 3>
v2 = <4, 5, 6>
EqualsAny(v1, v2) = True
I expected the result of EqualsAny in this case to return False.
I can see the issue when looking at the source code. It's converting to a Vector128, which has a hidden 4th component, that's always 0.
This affects other functions as well, such as LessThanOrEqualAny, and a lot of other new functions.
It also affects the same functions in Vector2, which also uses Vector128, so it would have the 3rd and 4th component as 0.
Reproduction Steps
using System.Numerics;
Vector3 v1 = new(1, 2, 3);
Vector3 v2 = new(4, 5, 6);
Console.WriteLine($"v1 = {v1}");
Console.WriteLine($"v2 = {v2}");
Console.WriteLine($"EqualsAny(v1, v2) = {Vector3.EqualsAny(v1, v2)}");
Expected behavior
v1 = <1, 2, 3>
v2 = <4, 5, 6>
EqualsAny(v1, v2) = False
Actual behavior
v1 = <1, 2, 3>
v2 = <4, 5, 6>
EqualsAny(v1, v2) = True
Regression?
No.
It's a new function in .NET 10.
Known Workarounds
No response
Configuration
No response
Other information
No response
Reactions are currently unavailable