Re: [csswg-drafts] [css-values-4] What is the unit of `round(A, B)` if `A` and `B` have different units? (#12690)

@Loirooriol Thanks. So my confusion here was actually due to me missing that `tan(atan2(A, B))` performs a unit conversion if the arguments are different units, meaning it doesn't matter if you do `tan(atan2(2rem, 1px))` or `tan(atan2(32px, 1px))` (yes assuming that 1rem ~ 16px), both will be 32. I assumed for some reason that this would ignore the units and evaluate to 2 and 32 respectively.

The reason for the inconsistent browser results in my codepen above is actually due to Firefox and Safari not handling `tan(atan2())` with different units, with Firefox just returning 0 in that case and Safari doing something weird that I don't quite the logic for (`tan(atan2(2rem, 1px))` somehow ends up as 0.250549?).

Here is another codepen that makes it clearer: https://codepen.io/maikelkrause/pen/gbaBBdY

In this codepen, I added `@property` declarations and now everything works fine in all browsers (apart from [Firefox's rounding error](https://bugzilla.mozilla.org/show_bug.cgi?id=1939353)). The need for `@property` is also mentioned [in this article](https://dev.to/janeori/css-type-casting-to-numeric-tanatan2-scalars-582j). If you remove the `@property` declarations then you'll see the behavior from my original codepen.

Will close this issue.

-- 
GitHub Notification of comment by mkrause
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12690#issuecomment-3240226792 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Sunday, 31 August 2025 15:34:52 UTC