Does anybody know if there is any power function added for SPARQL?
My quick-fix is using BIND and string process but it's not optimal at all:
?contract part:price ?price_E ;
part:Currency ?currency .
BIND(strafter(str(?price_E), "E") as ?E)
BIND(replace(strbefore(str(?price_E), "E"), "\[.\]", "") as ?nodot)
BIND(substr(?nodot, 0, xsd:integer(?E)+2) as ?first)
BIND(substr(?nodot, xsd:integer(?E)+2, 2) as ?second)
BIND(concat(?first, ".", ?second) as ?price)
Example of input and output data: Input 1.51535E3 Output 1515.35
Sadly, the answer is no. As of SPARQL 1.1, the current W3C version, there is no exponentiation operator. You can accomplish it with repeated multiplication (
x*x) as in:However, in your example, it is not clear that you actually need to do any arithmetic. The input
1.51535E3is in fact already equal to1515.35because it is valid scientific notation, which SPARQL supports.