Re: [eclipse-clp-users] Integer exponentiation in ic

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Wed, 08 May 2013 08:52:06 +0100
On 05/05/2013 02:34, Matthew Skala wrote:
> Exponentiation constraints don't seem to be exact; they produce real
> intervals bracketing the correct answer, even when evaluated on
> positive integers where the result must be integer too:
>
>     [eclipse 1]: lib(ic).
>     % blah blah
>     Yes (0.13s cpu)
>     [eclipse 2]: X#=2,Y#=2,Z#=X^Y.
>
>     No (0.00s cpu)
>     [eclipse 3]: X#=2,Y#=2,Z$=X^Y.
>
>     X = 2
>     Y = 2
>     Z = 3.9999999999999987__4.0000000000000018


This is clearly a bug, I've registered it as
http://eclipseclp.org/bugzilla/show_bug.cgi?id=747

You can use the following reformulation:

?- X #= 2, Y #= 2, integers([X, Y, Z]), Z $= X ^ Y.
X = 2
Y = 2
Z = 4
There are 3 delayed goals.
Yes (0.00s cpu)


Also, if Y is instantiated to an integer at compile time,
it behaves as expected:

?- X #= 2, Z $= X ^ 2.
X = 2
Z = 4
There is 1 delayed goal.
Yes (0.00s cpu)



-- Joachim
Received on Wed May 08 2013 - 07:52:20 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST