lllllllllllll
lllllllllllll

Reputation: 9140

Why it can not be calculated as an integer?

So basically in GNU-Prolog, I have some code like this:

....
( integer(X) -> write("TRUE"), nl
  ;             write("FALSE"), nl
),
write(X /\ 0xff), nl.

And according to the output, I am sure that X is and integer..

But what I am confused is that, the second output is something like this:

435321 /\ 0xff

and what I am expecting is the value of 435321 /\ 0xff...

What is wrong here? Could anyone give me some help?

Upvotes: 0

Views: 62

Answers (1)

Sergii Dymchenko
Sergii Dymchenko

Reputation: 7229

Prolog evaluates arithmetic expressions only in some specific situations (is, arithmetic comparisons, etc...)

You should do this: Result is X /\ 0xff, write(Result).

Upvotes: 2

Related Questions