Skip to content

When the type is a floating-point number, precision issues may arise. #545

Description

@kongbai1996

The generic PartialEq implementation for Size2D directly uses ==, which loses precision when the type is float. Size3D and Point2D have similar issues.
I added tests with floating-point numbers in the test_add function of Size2D, and indeed they failed:

let s1 = Size2D::new(0.1, 0.0);
let s2 = Size2D::new(0.2, 0.0);
assert_eq!(s1 + s2, Size2D::new(0.3, 0.0));
assert_eq!(s1 + &s2, Size2D::new(0.3, 0.0));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions