W3C home > Mailing lists > Public > www-svg@w3.org > November 1999

Re: is scientific notation allowed in numbers?

From: Chris Lilley <chris@w3.org>
Date: Sun, 14 Nov 1999 05:43:55 +0100
Message-ID: <382E3E0B.32A883F@w3.org>
To: Apu Nahasapeemapetilon <petilon@yahoo.com>
CC: www-svg@w3c.org

Apu Nahasapeemapetilon wrote:
> In path data, is it OK to output floating point
> coordinates in scientific notation?

> In other words, can I write
>    3.450000e-004
> instead of
>    0.000345

Yes, you can (although superfluous trailing and leading zeros should
ideally be omitted to minimise file size. Only use the precision that is
needed for the task). So in your example above, 3.45e-4 

> The specification should make it clear if this is
> allowed or not.

I agree. 

It is clear on close reading ;-) which means we should make it clearer
in the next draft, but I agree that all the exampkles currently use only
integer values and that section 10.3.1 should explicitly state that
floating point coordinates are allowed.

The grammar for path data shows that floating point is allowed:

         sign? integer-constant
         | sign? floating-point-constant

         fractional-constant exponent?
         | digit-sequence exponent

         digit-sequence? "." digit-sequence
         | digit-sequence "."

        ( "e" | "E" ) sign? digit-sequence

        "+" | "-"

        | digit digit-sequence

        "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

> Ideally the SVG spec must explicitly allow numbers
> in scientific notation so that SVG viewers will be
> prepared to handle this.

Existing viewers do handle this, that I have seen. I have not tested
them exhaustively. But it would be most odd if an existing viewer, which
supported the current latest public draft, did not support the path
syntax exactly as specified.

If anyone finds an implementation which fails on floating point
coordinates, please mail the maintainer of that software and refer them
to this URL:


Anyone have good tools that take a BNF and write a checker for
conformance to that BNF? 

That would be a handy thing to hook up to an XML parser (a SAX parser
would be adequate for this, though a DOM implementation would also work)
and have it check all paths in an SVG file.

Received on Saturday, 13 November 1999 23:44:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:53:48 UTC