Jan Martin Keil created JENA-1943:
-------------------------------------
Summary: Increase Precision of Decimal Calculation Results
Key: JENA-1943
URL: https://issues.apache.org/jira/browse/JENA-1943
Project: Apache Jena
Issue Type: Bug
Components: ARQ
Affects Versions: Jena 3.16.0, Jena 3.14.0
Reporter: Jan Martin Keil
The precision of calculation results with type {{xsd:decimal}} is limited
without need.
An Example:
{code:java}
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.rdf.model.ModelFactory;
import org.junit.jupiter.api.Test;
public class MaxDecimalDivissionPrecissionTest {
@Test
public void maxDecimalDivissionPrecission() {
String query = "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
"//
+ "SELECT"//
+ " (
STR(1/STRDT(\"1000000000000000000000000\", xsd:decimal)) AS ?times10)"//
+ " (
STR(1/STRDT(\"10000000000000000000000000\", xsd:decimal)) AS ?calculated)"//
+ "
(DATATYPE(1/STRDT(\"10000000000000000000000000\", xsd:decimal)) AS ?type)"//
+ " ( STR(
STRDT(\"0.0000000000000000000000001\", xsd:decimal)) AS ?direct)"//
+ " (
STR(1/STRDT(\"0.0000000000000000000000000000000000000000000001\", xsd:decimal))
AS ?large)"//
+ "WHERE {}";
System.out.println(QueryExecutionFactory.create(query,
ModelFactory.createDefaultModel()).execSelect().next().toString().replace(" (",
"\n("));
}
}
{code}
Output:
{code:java}
( ?times10 = "0.000000000000000000000001" )
( ?direct = "0.0000000000000000000000001" )
( ?calculated = "0.0" )
( ?large = "10000000000000000000000000000000000000000000000.0" )
( ?type = xsd:decimal )
{code}
I would expect {{?calculated == ?direct}}. This only affects very small
numbers, very large numbers are not affected. I also checked
[Wikibase|https://query.wikidata.org/#PREFIX%20xsd%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%20%0ASELECT%0A%20%20%28STR%281%2FSTRDT%28%221000000000000000000000000%22%2C%20xsd%3Adecimal%29%29%20AS%20%3Ftimes10%29%0A%20%20%28STR%281%2FSTRDT%28%2210000000000000000000000000%22%2C%20xsd%3Adecimal%29%29%20AS%20%3Fcalculated%29%0A%20%20%28STR%28%20%20STRDT%28%220.0000000000000000000000001%22%2C%20xsd%3Adecimal%29%29%20AS%20%3Fdirect%29%0A%20%20%28DATATYPE%28STRDT%28%220.0000000000000000000000001%22%2C%20xsd%3Adecimal%29%29%20AS%20%3Ftype%29%0A%20%20%28STR%281%2FSTRDT%28%220.0000000000000000000000000000000000000000000001%22%2C%20xsd%3Adecimal%29%29%20AS%20%3Flarge%29%0AWHERE%20%7B%7D]
and RDF4J and did not find this limitation. Please consider to remove this
limitation as I need the high precision in a view cases in a project.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)