Safari does better than Firefox, but better isn’t good.

Safari 16.3: some CSS:

--images: 1;
--count: round(up, calc(sqrt(var(--images))), 1);
results `--count == 2!`

As long as the numbers can be controled, you could do sth. like

--count: round(up, calc(sqrt(var(--images)) - 0.01), 1);

but … this is ugly! ceil(1) should be 1. Every calculator agree.

BTW: Firefox has one solution for every root. √x == 0!

Another issue: If --count is set to 1 as result of round: --count: calc(round(down, calc(sqrt(var(--images))), 1) + 1);

grid-template-columns: repeat(var(--count), 1fr);
grid-template-columns: 1fr;

isn’t the same (in Safari)! The first line results in 2 columns, not in one!

Looks like the same reason. Because

grid-template-columns: repeat(calc(var(--count) -0.01), 1fr);

gives one column.

Wow, did find some new kind of math! If you do sth. like calc(2em ⁄ 1em) you get 2em as result! No chance to do things like aspect-ratio-calculations. Try to use another “result”: calc(300% ⁄ 100%)!Aren’t 3% enough?

Update:

Hey, what’s this? The “Live Preview" shows / instead of the division slash? Fine, I try to find some replacement … and you have no luck with C&P!

“breaking news” — LOL

calc(sqrt(12.249 999 999 999 999 111 821 580 299 874 767 661 094 665 527 343 75)) results 4, calc(sort(12.249 999 999 999 999 111 821 580 299 874 767 661 094 665 527 343 749 999 999 999 999 999 99…)) results 3.

round(to-zero, x, y) results 0

How I found this number and round? Took calc(saqrt()) tu build a grid mostly square. Input: the total number of grid-items. Then I tried to figure out a solution, a combination of bugs, solving the problem (Safari ≠ WWW) && (Firefox ≠ WWW).

Happy new math! Computers do this very … fine?

BTW: the spaces in my examples are because of the forum software. Without them the numbers are “illegal”.

Another joke, but not with Safari or another WWW-browser as origin: did you know, you can’t calculate? Ok, not calculate, you can not CSS-calculate!

Try it, use the results for your tests. Find out, if the results are number or pixels (CSS or real ones), if they are percents or what else: calc(100vw ⁄ 100vh), calc(100cqw ⁄ 100cqh), calc(1em + 1vh) or calc(1em * 1vh), calc(10% * 1em) or calc(10% + 1em), … Did you graduate some school? What did your teachers telly you about your math? Or: about this … mhaff?

Safari still does another kind of math! It’s the only thing, computer or calculator, making ceil(a) to return (ceil(a)==a) ? a+1 : ceil(a); [https://w3c.github.io/csswg-drafts/css-values/#funcdef-round%5D(%E2%80%9CIf A is exactly equal to an integer multiple of B, round() resolves to A exactly”)

This reply is just a test, trying to reproduce this issue.

Safari does better than Firefox, but better isn’t good.
 
 
Q