0

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?

false
  • 10,533
  • 12
  • 98
  • 192
lllllllllllll
  • 7,731
  • 7
  • 39
  • 72

1 Answers1

2

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

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

Sergii Dymchenko
  • 6,567
  • 1
  • 20
  • 42