Hello, I remember an old discussion about vectors of floats saved using the C99 hexadecimal notation. However, a colleague found out that also a simple float property map is saved using that notation and this is giving him troubles of interoperability. As an example from graph_tool.all import * g = Graph() n = g.add_vertex() n1 = g.add_vertex() e = g.add_edge(n,n1) p = g.new_edge_property('float') p[e]=3.14 g.edge_properties['weight']=p g.save('float-test.xml') float-test.xml then contains: ... <key id="key0" for="edge" attr.name="weight" attr.type="float" /> ... <edge id="e0" source="n0" target="n1"> <data key="key0">0x1.91eb851eb851fp+1</data> </edge> Is this the expected behaviour? Also, there is no difference if we change the type from float to double. Thanks, Giuseppe
On 12/12/2013 02:41 PM, Giuseppe Profiti wrote:
Hello, I remember an old discussion about vectors of floats saved using the C99 hexadecimal notation. However, a colleague found out that also a simple float property map is saved using that notation and this is giving him troubles of interoperability.
As an example
from graph_tool.all import * g = Graph() n = g.add_vertex() n1 = g.add_vertex() e = g.add_edge(n,n1) p = g.new_edge_property('float') p[e]=3.14 g.edge_properties['weight']=p g.save('float-test.xml')
float-test.xml then contains: ... <key id="key0" for="edge" attr.name <http://attr.name>="weight" attr.type="float" /> ... <edge id="e0" source="n0" target="n1"> <data key="key0">0x1.91eb851eb851fp+1</data> </edge>
Is this the expected behaviour? Also, there is no difference if we change the type from float to double.
Yes, this is expected. Remember that floating types (either float or double) do not have an exact decimal representation. In order to guarantee that no information is lost, the hexadecimal representation is used. Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
Giuseppe Profiti -
Tiago de Paula Peixoto