[whatwg] Common number formats
Ian Hickson
ian at hixie.ch
Mon Jun 11 13:37:54 PDT 2007
On Tue, 25 Apr 2006, Henri Sivonen wrote:
>
> I assume number formats in attributes consistently do not allow
> whitespace before and after. Am I right?
The spec says (for unsigned integers):
# A string is a valid non-negative integer if it consists of one of more
# characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).
Since space characters aren't in the range U+0030 to U+0039, they are not
allowed, whether at the start, middle, or end.
> I assume that an explicit + sign is always forbidden. Correct?
The spec says:
# A string is a valid integer if it consists of one of more characters in
# the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), optionally
# prefixed with a U+002D HYPHEN-MINUS ("-") character.
> Is the - sign forbidden in front of zero? (Would be logical considering
> that the explicit plus is forbidden.)
The - is always allowed, per the text above.
> Most definitions of integers allow leading zeros but the width and
> height for canvas don't. Is this intentional?
This has been fixed.
> I guess floats allow leading zeros as well. Correct?
# A string is a valid floating point number if it consists of one of more
# characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
# optionally with a single U+002E FULL STOP (".") character somewhere
# (either before these numbers, in between two numbers, or after the
# numbers), all optionally prefixed with a U+002D HYPHEN-MINUS ("-")
# character.
> Do percentages allow leading zeros? (Leading zeros are harmless in
> Firefox, Opera and Safari, at least.)
I haven't defined percentages yet, as we may not need them. But I imagine
I would define them as being just a kind of integer followed by a "%"
character.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list