[
https://issues.apache.org/jira/browse/JENA-1370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076324#comment-16076324
]
Andy Seaborne edited comment on JENA-1370 at 7/6/17 10:33 AM:
--------------------------------------------------------------
See also JENA-1303.
{{"-1.700000e+00"\^\^xsd:double}} and {{"-1.7E0"\^\^xsd:double}} are different
RDF terms representing the same value.
{{isIsomorphicWith}} compares by RDF term, not by values.
A related example is a graph
{noformat}
:s :p -1.700000e+00 .
:s :p -1.7E0 .
{noformat}
has two triples so has a different triple count to
{noformat}
:s :p -1.7E0 .
{noformat}
There is a general, and slower (for large graphs), matcher in {{IsoMatcher}}.
You can take that code and provide {{NodeUtils.sameValue`}}. Unfortunately, the
necessary call is private in the current release but the code is open source.
It will be public in 3.4.0.
Where value comparison is important, canonicalising the terms on input gives
consistent behaviour. {{RDFParser}} has the ability to add a "canonicalize
literals" step.
was (Author: andy.seaborne):
See also JENA-1303.
{{"-1.700000e+00"\^\^xsd:double}} and {{"-1.7E0"\^\^xsd:double}} are different
RDF terms representing the same value.
{{isIsomorphicWith}} compares by RDF term, not by values.
A related example is a graph
{noformat}
:s :p -1.700000e+00 .
:s :p -1.7E0 .
{noformat}
has two triples so has a different triple count to
{noformat}
:s :p -1.7E0 .
{noformat}
There is a general, and slower (for large graphs), matcher in {{IsoMatcher}}.
You can take that code and provide {{NodeUtils.sameValue`}}. Unfortunately, the
necessary call is private in the current release but the code is open source.
It will be public in 3.4.0.
> Exponent values
> ----------------
>
> Key: JENA-1370
> URL: https://issues.apache.org/jira/browse/JENA-1370
> Project: Apache Jena
> Issue Type: Bug
> Components: Jena
> Affects Versions: Jena 3.2.0
> Environment: Java 1.8, Ubuntu Linux (xenial)
> Reporter: Daan Reid
>
> The equality between float values appears to be not working as I expected.
> Example code:
> {code:java}
> @Test
> public void testDeltaSimple() throws Exception {
> Graph oldGraph = GraphFactory.createGraphMem();
> Graph newGraph = GraphFactory.createGraphMem();
> // oldGraph:
> // <http://example.com/subject> <http://example.com/property>
> -1.700000e+00 ;
> // newGraph:
> // <http://example.com/subject> <http://example.com/property> -1.7E0 ;
> RDFDataMgr.read(oldGraph, "oldGraph.ttl");
> RDFDataMgr.read(newGraph, "newGraph.ttl");
> Delta delta = new Delta(oldGraph);
> delta.clear();
> GraphUtil.addInto(delta, newGraph);
> if (!delta.isIsomorphicWith(oldGraph)) {
>
> System.err.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
> RDFDataMgr.write(System.err, delta.getAdditions(), Lang.TURTLE);
>
> System.err.println("-------------------------------------------------------------------------------------");
> RDFDataMgr.write(System.err, delta.getDeletions(), Lang.TURTLE);
> fail("!!!!!!!!!!!!!!!!!!!!!! RDF not equal");
> }
> }
> {code}
> Result:
> {noformat}
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> -------------------------------------------------------------------------------------
> <http://example.com/subject>
> <http://example.com/property> -1.700000e+00 .
> java.lang.AssertionError: !!!!!!!!!!!!!!!!!!!!!! RDF not equal
> {noformat}
> If I start with an empty graph for oldGraph, the new double value is properly
> added.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)