Re: [css3-values][css3-syntax] E notation, very small and very large values

Tab Atkins Jr.:
> On Fri, Aug 27, 2010 at 5:22 AM, Christoph Päper
>>> 
>>>  h1 { font-size: 2.6e-4em }
>> 
>> Uch, it really looks like 2.6 e minus 4 em.
> 
> Subtraction isn't valid outside of calc().

  h1 {font-size: calc(2.6e-4em)}

doesn’t look any less like substraction. Don’t mind the whitespace rules.

> These types of numbers can be useful, for example, for serializing transformation matrices.

I guess they’re used in the Transformations and Animations drafts which I haven’t checked out yet. Anyhow, do you need units there? Unitless, E notation looks less evil (still evil, though).

> If we were solving this problem for the first time, it would make sense to look at multiple solutions.

It still does, at least where units are involved.

> We're not, though - SVG already has a notation for small/large numbers that would be nice to reuse if it isn't too horrible.

I thought it was breaking the (core) grammar, which I would value as horrible. 
But it seems units, i.e. everything after the first, numeric part of DIMENSION, are defined as just {ident} which is (without escaping and Unicode) “[-]?[_a-z][_a-z0-9-]*” where I would have expected something like “[_a-z-]+” or “[-]?[_a-z]|[-]?[_a-z][_a-z-]*[a-z]”. {ident} includes “[e][-]?[0-9]+{ident}”, except that e.g. “2.6e-4-5” and “2.6e-4-5em” were legal, too, where “0.00026-5” and “0.00026-5em” would not have been.

The ‘e’ and exponent cannot be part of NUMBER = {num} in CSS (without changing the grammar) and therefore even a unitless number is parsed as DIMENSION. Otherwise it works like SI prefixes in ‘cm’ or ‘mm’ , which is kind of odd, because you’re introducing an infinite amount of unit prefixes.

I also dislike the plus sign being illegal where the minus sign can be used.

> it's a common, well-known notation used fairly regularly in handwritten math and science (…)

I’ve never seen it handwritten, except, perhaps, from 8th-graders (or so) who just copied whatever their calculator spilled at them.

> Authors are familiar with it,

Some are familiar with {num}[e][-]?[0-9]+, but noone is used to {num}[e][-]?[0-9]+{ident}.

> SVG is already using it,

And never should have been, just like X11 color names etc.

> it's compact and easily understandable,

Like #ABCDEF colors, it’s a coder style that is opaque to newbies. “2e3” can be guessed as meaning 8 at least as easy as it meaning 2000.

> and it's completely unambiguous.

Technically maybe, but not necessarily so for authors, who might read “2.6e-4em” and think: “Huh, you can do substraction in CSS? But the author forgot a letter, I’ll just fix and evaluate it to ‘-1.4em’, whatever that does.”

Received on Saturday, 28 August 2010 10:49:22 UTC