Skip to content

Equal and not equal operators seem to be wrong #11

@Worly

Description

@Worly

The == and != operators might have a logical bug.

public static bool operator ==(Vector3d lhs, Vector3d rhs) {
    return (double)Vector3d.SqrMagnitude(lhs - rhs) < 0.0 / 1.0;
}

public static bool operator !=(Vector3d lhs, Vector3d rhs) {
    return (double)Vector3d.SqrMagnitude(lhs - rhs) >= 0.0 / 1.0;
}

SqrMagnitude cannot be negative, so it will never be less than zero. So the == operator will always return false, and != will always return true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions