From: Aryeh Gregor <Simetrical+w3c@gmail.com>

Date: Wed, 22 Jul 2009 01:01:06 +0000

Message-ID: <7c2a12e20907211801x4041737bw9188277a0bdd93a6@mail.gmail.com>

To: "Belov, Charles" <Charles.Belov@sfmta.com>

Cc: www-style@w3.org, François REMY <fremycompany_pub@yahoo.fr>

Date: Wed, 22 Jul 2009 01:01:06 +0000

Message-ID: <7c2a12e20907211801x4041737bw9188277a0bdd93a6@mail.gmail.com>

To: "Belov, Charles" <Charles.Belov@sfmta.com>

Cc: www-style@w3.org, François REMY <fremycompany_pub@yahoo.fr>

On Tue, Jul 21, 2009 at 11:55 PM, Belov, Charles<Charles.Belov@sfmta.com> wrote: > I see that the minimum operator for the calc function is not currently part of the working draft and is considered as a future operator for calc. > > I believe the need for choosing between the minimum of two max-widths would be a justification for including the minimum operator in the working draft. Are browsers support to support mod for floating-point numbers? Because if val - val mod 1 is equivalent to, for instance, floor(val) (as in Python), then you could do something like min(x, y) = 0.5*(x + y - abs(x - y)) abs(x) = sgn(x)*x sgn(x) = 2*(x/1000000 - (x/1000000) mod 1) + 1 (if x is reasonably small) Thus >>> def f(x, y): ... return 0.5*(x + y - (2*((x - y)/1000000 - ((x - y)/1000000) % 1) + 1)*(x - y)) ... >>> f(7, 14.2) 7.0 >>> f(7, 6.4) 6.4000000000000004 >>> f(-31, 927) -31.0 >>> f(-8, -19) -19.0 Also, you know you can do trig functions, exponentials, and logarithms using Taylor series, right? Actually, you can do any function differentiable on the complex plane in a disk containing the range of values you have to deal with! Who said a good grounding in analysis isn't useful in real life? :D . . . okay, now, seriously. A few issues here: 1) The mod operator has to be defined better. What does it do with floating-point numbers, and what does it do with negative numbers? I'd say it should definitely be defined to handle floating-points as expected. For negative numbers, I don't know, they don't come up too often in CSS. The spec should clarify this in any event. 2) A min() function would definitely be very useful. There would surely be no problem in implementing it, right? 3) I can *guarantee* that some hacks rather like the above will appear if not enough useful functions are added. We added an #expr function on Wikipedia that originally supported mostly basic arithmetic. IIRC, we literally had people on Wikipedia manually writing out Taylor series for sine and cosine to generate CSS that would position an arbitrary number of things evenly spaced around circles of arbitrary radius. I wish I was kidding. But I'm not, so be prepared. :) Eventually we caved and added a whole bunch of math functions so people wouldn't have to resort to such hacks. If the implementation burden isn't much greater, I think it would be a good idea to define a bunch of standard math functions in calc() from the get-go to avoid this kind of scenario. Authors *will* want to use min and max, and if they have to resort to a function like I gave here, some of them will . . .Received on Wednesday, 22 July 2009 01:01:47 UTC

*
This archive was generated by hypermail 2.3.1
: Wednesday, 11 February 2015 12:34:27 UTC
*