Skip to content

Issues with Vector3.EqualsAny #123586

@talanc

Description

@talanc

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions