Re: [csswg-drafts] [css-values-5] Make UA, not author, deal with floating point errors in random() (#11864)

So this will basically have 2 effects:

 1. If the distance from the min to the max is very slightly smaller than a multiple of the step, then the proposal adds the maximum as a possible option.
      
      For example consider `random(0, 0.3, by 0.1)` with f64 precision. 0.3 is slightly smaller than 0.1*3, so:
       - Current: it chooses among 0, 0.1, 0.2
       - Proposal: it chooses among 0, 0.1, 0.2, 0.3

 2. If the distance from the min to the max is very slightly greater than a multiple of the step, then the proposal replaces the last option with the maximum.
      
       For example, consider `random(0, 1.8, by 0.6)` with f64 precision. 1.8 is slightly greater than 0.6*3, so:
       - Current: it chooses among 0, 0.6, 1.2, 1.7999999999999998
       - Proposal: it chooses among 0, 0.6, 1.2, 1.8

Sounds reasonable. I would choose a threshold smaller than 1%, though.

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


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

Received on Monday, 10 March 2025 01:28:18 UTC