Simon,
On Mon, Jun 15, 2009 at 5:03 PM, Simon Strobl<
Simon.Strobl@...> wrote:
>
> thank you for the interesting discussion. The most straightforward solution
> for my problem was to convert all my numbers to floats before comparing
> them. I suppose an analogous solution can be used in the vast majority of
> cases in which someone has a problem with compare/3.
A corollary from the above discussion is: as long as you stick with
small integer values, you will get the illusion that float( X ) == X
for X integer.
Here is what I get on this 64 bit machine:
?- X is integer( 1e+23 ), Y is float( X ), X =:= Y.
X = 99999999999999991611392,
Y = 1e+23.
?- X is integer( 1e+22 ), Y is float( X ), X =:= Y.
X = 10000000000000000000000,
Y = 1e+22.
?- X is integer( 1e+22 ), Y is float( X ), X =:= Y, X == Y.
false.
Shocking, isn't it ? 1e+22 is not *that* big a number. So I would
rather think that if I have a problem with compare/3, then it is a
sign I am attempting to compare oranges to apples.
Regards,
--
Nicolas
_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog