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

Does Clingo support floating-point number? #515

Open
navdeepkjohal opened this issue Jul 22, 2024 · 1 comment
Open

Does Clingo support floating-point number? #515

navdeepkjohal opened this issue Jul 22, 2024 · 1 comment

Comments

@navdeepkjohal
Copy link

Hello,

Can you please tell me if clingo supports floating -point numbers or not?

I have a fact that says "one batch has 1.5 gallons of coffee. ". I want to write it as batch_size_gallons(1.5). but clingo reads the decimal after 1 as a full stop and throws an error that says:

:3:21-22: error: syntax error, unexpected ., expecting ) or ;

The google search says that floating-point numbers are not supported by Answer-set programming. I am just checking if there is any work-around this that I do not know of.

Thanks
Navdeep

@rkaminsk
Copy link
Member

rkaminsk commented Jul 22, 2024

Clingo does not support floats. It is possible to use them during grounding by using its API:

#script (python)
import math
from clingo.symbol import String
def sqrt(x):
    return String(repr(math.sqrt(float(x.string))))
#end.
p(@sqrt("17.3")).

See also our list: https://sourceforge.net/p/potassco/mailman/potassco-users/thread/0d78fb1b0eef6ddd729a856c013b79d2037a8bd8.camel%40cs.uni-potsdam.de/#msg37606655

Edit: I believe there was a paper once about extending ASP with floats. Unfortunately, I don't remember the title.

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