Skip to content

Fuzzy equality requires precision of 11 while dart-sass only has precision of 10 #3953

@ntkme

Description

@ntkme

https://github.com/sass/sass/blob/main/spec/types/number.md#fuzzy-equality

They are both finite numbers and the mathematical numbers they represent produce the same value when rounded to the nearest 1e⁻¹¹ (with ties away from zero).

In my understanding, "precision of 10" means two internal numbers are considered equal if they are equal after rounding them up to 1e⁻¹⁰, . In other words, with dart-sass being precision of 10, if two SassNumbers serialize to the same String after rounding, they should be equal, however, I discovered that fuzzy equality requires a precision of 11 in spec instead of precision of 10, which leads to a very confusing situation.

https://sass-lang.com/playground/#eJwzNFRJtFIw0DMwNDI2MTUzt7C05lJJQhUxMQWKJcaX5McXWykoV6sk1oLUIPhJQD5XSWpxiUI1l4JCamFpYk5mSaVuYrFucUlRZl66lQJUt4KtrQJUozWayrzS3KTUIpBKiCJrrloAgV8sUQ==

> a = SassNumber(0.0123456789)
0.0123456789
> b = SassNumber(0.012345678945)
0.0123456789
> a.toString() == b.toString()
true
> a.equals(b)
false

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestunder considerationThe Sass team is debating whether to do this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions