Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swrlb:divide built-in fails with decimal arguments #39

Open
LorenzBuehmann opened this issue Dec 25, 2017 · 1 comment
Open

swrlb:divide built-in fails with decimal arguments #39

LorenzBuehmann opened this issue Dec 25, 2017 · 1 comment

Comments

@LorenzBuehmann
Copy link

LorenzBuehmann commented Dec 25, 2017

Reported first on StackOverflow.

Setup

Protege 5.2.0
SWRLTab Protege Plugin 2.0.5

Problem

Using swrlb:divide seems to fail during some weird numeric conversions, see this standalone SQWRL query

swrlb:divide(?r, 5.0, 3.0) -> sqwrl:select(?r)

Exception:

Exception running SQWRL query S1: error running SQWRL queries: error running Drools rule engine:
[Error: invoker.invoke("S1", "swrlb:divide", 0, false, new VPATH(), new BAVNs("r", "", ""), new UBA("r"), new L("5.0", "xsd:decimal"), new L("3.0", "xsd:decimal")): runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.]
[Near : {... invoker.invoke("S1", "swrlb:di ....}]
             ^
[Line: 1, Column: 1]: runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.: error running Drools rule engine:
[Error: invoker.invoke("S1", "swrlb:divide", 0, false, new VPATH(), new BAVNs("r", "", ""), new UBA("r"), new L("5.0", "xsd:decimal"), new L("3.0", "xsd:decimal")): runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.]
[Near : {... invoker.invoke("S1", "swrlb:di ....}]
             ^
[Line: 1, Column: 1]: runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.: [Error: invoker.invoke("S1", "swrlb:divide", 0, false, new VPATH(), new BAVNs("r", "", ""), new UBA("r"), new L("5.0", "xsd:decimal"), new L("3.0", "xsd:decimal")): runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.]
[Near : {... invoker.invoke("S1", "swrlb:di ....}]
             ^
[Line: 1, Column: 1]: runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.: Non-terminating decimal expansion; no exact representable decimal result.

On the other hand, probably due to different implementation, the swrlm:eval extension works, try

swrlm:eval(?r, "5.0/3.0") -> sqwrl:select(?r)

Result:
"1.6666666666666667"^^xsd:double

I guess, something is different with the literal conversion, the latter seems to use xsd:double literals, while the former works with xsd:decimal - but it's just a guess. By the way, XPath also uses either xsd:int or xsd:decimal.

@martinjoconnor
Copy link
Member

martinjoconnor commented Jan 9, 2018

Thanks for the report. I will take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants