- From: mkrause via GitHub <noreply@w3.org>
- Date: Sat, 30 Aug 2025 19:23:01 +0000
- To: public-css-archive@w3.org
mkrause has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-values-4] What is the unit of `round(A, B)` if `A` and `B` have different units? == In the expression `round(2rem, 1px)`, what would be the unit of the resulting length? Is it even defined? Here are some test cases: https://codepen.io/maikelkrause/pen/yyBxJPg The codepen above gives different results (for test case 2 and 3) in all three major browsers. (Note: I assumed that Chrome's implementation is the correct one so those are marked as "passing", but this is what I want to double check in this issue.) It uses `tan(atan2())` to extract the scalar part of a dimensional value. - Chrome 139: (1) 32px, (2) 32px, (3) 32px - Firefox 142: (1) 31.9999px, (2) 31.9999px, (3) 0px - Safari 18.6: (1) 32px, (2) 0.250549px, (3) 0.250549px From [the spec](https://www.w3.org/TR/css-values-4/#round-func): > The `round(<rounding-strategy>?, A, B?)` function contains an optional rounding strategy, and two calculations A and B, and returns the value of A, rounded according to the rounding strategy, to the nearest integer multiple of B either above or below A. The argument calculations can resolve to any <number>, <dimension>, or <percentage>, but must have a consistent type or else the function is invalid; the result’s type will be the consistent type. > > If A is exactly equal to an integer multiple of B, `round()` resolves to A exactly The spec mentions that the result may be (1) the nearest integer multiple of B (implies the unit of B?), or (2) A exactly (implies the unit of A?). (This may be related to #7482.) Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12690 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 30 August 2025 19:23:02 UTC