Re: [csswg-drafts] [css-values] Emulate conditionals with discontinuous function(s) in calc() (#6638)

No, `max(0, var(--x)) / var(--x)` is NaN for 0. Use [`sign()`](https://drafts.csswg.org/css-values-4/#funcdef-sign) instead, this usecase was the reason I proposed it in #4673

So "use x^2 if x is positive but use 2*x if x is negative (and use +0 if x is ±0)" is

```css
calc(max(0, sign(var(--x))) * pow(var(--x), 2) - min(0, sign(var(--x))) * 2 * var(--x))
```

In https://github.com/w3c/csswg-drafts/issues/4731#issuecomment-581312064 I wrote a summary for writing `if(cond, then, else)` in terms of `sign()`.

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


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

Received on Sunday, 19 September 2021 19:29:30 UTC