Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
L
librsvg
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 178
    • Issues 178
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 8
    • Merge Requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • librsvg
  • Issues
  • #215

Closed
Open
Created Mar 02, 2018 by Federico Mena Quintero@federicoMaintainer

Remove float comparisons with ==

We do some float comparisons with ==, which is wrong in some cases, and the clippy lints rightfully complain:

warning: strict comparison of f32 or f64
   --> rsvg_internals/src/path_builder.rs:127:24
    |
127 |         if x1 == x2 && y1 == y2 {

warning: strict comparison of f32 or f64
   --> rsvg_internals/src/pattern.rs:417:27
    |
417 |     if scwscale != 1.0 || schscale != 1.0 {

In the first case (arbitrary x1 == x2), see this issue against float-cmp, about comparing floats against (possibly) zero. We can experiment with having a local ApproxEqEpsilonOrUlps trait, with the epsilon adjusted to the smallest fixed-point number that Cairo can represent. Or something like that: each comparison needs to be considered independently.

In the second case (scwscale != 1.0), I think we can just use float_cmp::ApproxEqUlps since we are not comparing against zero.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None