In DOT language, what is the text format for double-precision edge "len"?

According to reference [1], edge attribute “len” is a “double”. In most languages, one can specify a double precision number with format like 2.22045e-16. I created a DOT file containing edge specification “C – D [len=2.22045e-16]”, but this generates the following error

Warning: syntax ambiguity - badly delimited number ‘2.22045e’ in line 10 of PortDist.dot splits into two tokens

Error: PortDist.dot: syntax error in line 10 near ‘-16’

How does one specify a double precision edge length in DOT?

NOTES
[1] When I post the URL, I am told that I cannot link to that host. In words, the URL is graphviz dot org slash docs/attrs/len. What’s even more puzzling is that I previously posted a question in which I successfully provided that URL unmangled.

Here’s one of the places we parse the len attribute: https://gitlab.com/graphviz/graphviz/-/blob/main/lib/neatogen/stuff.c#L119

We use sscanf() with the %lf format string, which I think means long-float or double?

Another place we parse the len attribute is in init_edge: https://gitlab.com/graphviz/graphviz/-/blob/main/lib/fdpgen/fdpinit.c#L69
Which calls late_double: https://gitlab.com/graphviz/graphviz/-/blob/main/lib/common/utils.c#L90
Which parses with strtod.

I hope sscanf and strtod have the same behaviour!

1 Like

According to scanf format string - Wikipedia, “%f” and “%lf” expect fixed-point notation. Exponential notation is specifed using “%g”. So that must be the explanation. Thanks.