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:pow negative value? #87

Open
vChavezB opened this issue Jan 5, 2025 · 0 comments
Open

swrlb:pow negative value? #87

vChavezB opened this issue Jan 5, 2025 · 0 comments

Comments

@vChavezB
Copy link

vChavezB commented Jan 5, 2025

It would be nice if swrlb:pow would accept negative values.

I get an invalid math operation error with a negative pow value

https://github.com/protegeproject/swrlapi/blob/5b89d824541899255bc858aeca4a9c4f4b585882/src/main/java/org/swrlapi/builtins/swrlb/SWRLBuiltInLibraryImpl.java#L1527C6-L1527C8

It seems that BigDecimal requires a math context when using negative

https://stackoverflow.com/a/9932295

If not, by default a BigDecimal will only accept pow with positive numbers.

Alternative for my use case:

Add a second SWRL rule that processes negative pows with division (1/pow(10,x))

swrlb:lessThan(?power_neg,0) ^ swrlb:abs(?abs_val,?power_neg)^swrlb:pow(?pow_val,10,?abs_val) ^ swrlb:divide(?result,1.0000,pow_val) -> my_consequents_here

vChavezB added a commit to vChavezB/swrlapi that referenced this issue Jan 17, 2025
Mathcontext is required to allow the use of
negative values as second argument for a pow
operation with BigDecimal.

Fixes protegeproject#87
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

1 participant