I have the following Jena Rule to perform addition:
@prefix pm: <http://example.org/ProductionMesure#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix pr: <http://example.org/Production#>.
[r1:
(?mesCavTur rdf:type pr:Mesure)
(?cavTur owl:ensemble_de ?mesCavTur)
noValue(?cavTur owl:valeur ?x)
->
(?cavTur owl:valeur 0.0)
]
[r2:
(?mesCavTur rdf:type pr:Mesure)
(?mesCavTur owl:valeur ?valeur)
noValue(?mesCavTur pm:flag pm:done)
(?cavTur owl:ensemble_de ?mesCavTur)
(?cavTur owl:valeur ?oldValeur)
sum(?valeur, ?oldValeur, ?somme)
->
drop(4)
(?cavTur owl:valeur ?somme)
(?mesCavTur pm:flag pm:done)
hide(pm:flag)
]
The rule is working almost correctly to perform the desired addition result. The problem which I have is that the values that are being passed into the sum function are both floats, but the returned value (?somme) comes back as a double.
The unexpected result from this is that it adds a small decimal number to the result (which I assume has something to do with the type conversion).
For example if I want to find the sum of three values 2.2, 2.5, and 2.7; the result I obtain is 7.1000000953674316 (which is close but not quite right).
Is there a way using this Jena rule, that I might be able to convert my float values (?valeur & ?oldValeur) into type double, then perform the sum function with these new double values, then finally convert the output (?somme) into a float value?
I think by doing this the extra decimal places may not be added to my output.