Re: [eclipse-clp-users] Configure a unification to specify when two floats should be considered equal?

From: Marco Gavanelli <marco.gavanelli_at_...17...>
Date: Tue, 09 Feb 2010 12:06:07 +0100
-dp- wrote:
> Is there a way to configure a particular call to unification to require that
> any floats or doubles within the compounds should be considered equal if,
> say, they are the same up to some configured number of decimal places?
> For example, I would like to provide some argument to operator = here,
>   p(X) = p(Y)           or    =(p(X), p(Y))
> so that if X and Y happen to be the same for their integer part and the
> first, say, three significant digits of their fractional part, then the
> unification should succeed.
> I'm pretty sure there is no such feature, but it seemed worth asking since
> unifying is fairly pointless if the args are compounds and there's a chance
> there's a float somewhere in either of them.
> The best alternative I can think of is to write my own unifier predicate and
> add this feature.

Maybe one solution could be to use the IC library or the RIA library (I 
am not sure if RIA still exists), see, eg., the comparison in the manual:

and then use the equality constraint instead of unification.


Marco Gavanelli, Ph.D. in Computer Science
Dept of Engineering
University of Ferrara
Received on Tue Feb 09 2010 - 11:06:29 CET

This archive was generated by hypermail 2.3.0 : Mon Aug 26 2019 - 09:14:36 CEST