Skip to content

[cssom] Is round special in CSSOM? #5689

Closed
@svgeesus

Description

@svgeesus

Context: moving the serialization of <color> values from CSSOM to CSS Color 4, per CSSWG resolution. I'm just checking that the new Color serialization section has everything needed before sending a PR to replace the corresponding part of CSSOM with a pointer.

Several times in Serializing CSS Values I see the phrase:

rounded to the closest integer (rounding up if two values are equally close)

Looking at the documentation of JavaScript Math.round

If the fractional portion of the argument is greater than 0.5, the argument is rounded to the integer with the next higher absolute value. If it is less than 0.5, the argument is rounded to the integer with the lower absolute value. If the fractional portion is exactly 0.5, the argument is rounded to the next integer in the direction of +∞.

and again for C++

Returns the integral value that is nearest to x, with halfway cases rounded away from zero.

Then, for positive numbers, this seems to be merely a restatement of part of the algorithm. In other words, the next decimal digit after the place to be rounded can take any one of ten values: 0,1,2,3,4,5,6,7,8,9 and of those, half of them (0,1,2,3,4) round down and half (5,6,7,8,9) round up.

Thus, is there utility in retaining this wording? Or is it enough to just say "round". I'm happy either way, just want the Color 4 spec to be complete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.Commenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.css-values-4Current Workcssom-1Current Work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions