[eclipse-users] Operators in Eclipse

From: Marconcini Cristina <marconcini_at_sci.univr.it>
Date: Wed, 04 Apr 2007 20:19:52 +0200
Dear All,


I would like to submit you a question about the division operator in Eclipse.
I am sorry because It should be trivial, but perhaps
there is something that I haven't seen.
 
I need to perform a division with variables and get the integer quotient.
In fact I will need to define a proper predicate like 
div_pr(X,2,Y) where X is the dividend and Y the result.

I have tried this and I have loaded the ic library.

Yes (0.00s cpu)
?- Y :: 0 .. 5, X :: 0 .. 5, Y #= X / 2, X #= 1.
No (0.00s cpu)
?- Y :: 0 .. 5, X :: 0 .. 5, Y #= X / 2, X #= 0.
Y = 0
X = 0
Yes (0.00s cpu)

So, I have checked on the manual where it is written that // return the integer
quotient

?- Y :: 0..5, X :: 0..5, Y #= 3//2, X#=0.
Y = 1
X = 0
Yes (0.00s cpu)
?- Y :: 0..5, X :: 0..5, Y #= X//2, X#=0.
Abort

but it works only with integer number and not with variables.

In fact, in the manual 

    E1 / E2        division                   number x number      see below
    E1 // E2       integer division truncated integer x integer    integer
    E1 rem E2      integer remainder          integer x integer    integer
    E1 div E2      integer division floored   integer x integer    integer
    E1 mod E2      integer modulus            integer x integer    integer

So, I can do this? Is it wrong my procedure?

Another small question. Is there a function to perform shifts that works with
variable and not only integers as parameters, like the operator <<(+Number1, +Number2, -Result) ?

Thank you 

Cristina
Received on Wed Apr 04 2007 - 19:19:48 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:57 CET