Re: [csswg-drafts] [css-values] Add round()/floor()/ceil() functions (#2513)

> And yes, I definitely think that authors would expect round(2.4cm) to produce 2cm, which we can't guarantee; we need to require the author the author to say round(2.4cm, 1cm).

Why? Why not default to using the unit that is next to the number, so that `round(2.4cm)` is the same as `round(2.4cm, 1cm)`, `round(2.4em)` is the same as `round(2.4em, 1em)`, `round(2.4)` is the same as `round(2.4, 1)`, etc.? Or, put another way, `round(2.4cm)` is the same as `calc(round(2.4) * 1cm)`. If there are two units, then use the first unit, so that `round(2cm + 19px)` is the same as `round(2cm + 19px, 1cm)`. This would just be, what do you call it, syntax sugar? But it sure would make it simpler to read and author.

Being able to use single parameters in the most common use cases is an important ease of use consideration. You don’t then need to recall if they are space separated or comma separated, for one thing, or which parameter comes first. Which is also why I favor multiple functions instead of extra parameters. I would much prefer to be able to do this:

```
round(2.4cm)
round-up(2.4cm)
round-down(2.4cm)
round-from-zero(2.4cm)
round-to-zero(2.4cm)
```

To me, that is much simpler and easier to remember and understand. I’m not a math major, and it is super clear. In my mind, it is hands down much, much better than this:

```
round(nearest, 2.4cm, 1cm)
round(up, 2.4cm, 1cm)
round(down, 2.4cm, 1cm)
round(from-zero, 2.4cm, 1cm)
round(to-zero, 2.4cm, 1cm)
```

Then, if I want to use a different precision, that is the only time I need a second parameter. And if it is a number, use the same unit as the first parameter. So, `round(2.4cm, 5)` == `round(2.4cm, 5cm)`, and `round(2cm + 19px, 10)` == `round(2cm + 19px, 10cm)`. 

——

I don’t really follow what `mod()` or `rem()` are (I guess `mod()` means modulo?), or when you need them. The abbreviations tend to obscure their meaning. I always thought rem meant “root em” in CSS. Are these included just for completeness, or for people who want CSS to look hard to grok, or what? If `rem` is the same thing as `round-to-zero`, then what’s the point?

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

Received on Saturday, 25 January 2020 06:56:12 UTC