Re: can't do simple division with / operator
Jan Burse, created Mar 27. 2017
Yes the following is correct ISO conforming behaviour:
?- 3 is 6/2.
The reason is simple, (/)/2 returns always a float value(*), and the present case it gives 3.0. But during term unification float values are different from integer values, here 3.
You can instead do the following and use another ISO predicate:
?- 3 =:= 6/2.
The predicate (=:=)/2, in contrast to term unification, is able to compare integers and floats, and should be used in number comparison.
(*) SWI-Prolog returns integer when it can so, but this
is not required by the ISO core standard.