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:

http://87.230.22.228/doc/libman/libman017.html#toc13

and then use the equality constraint instead of unification.

Best,
Marco

-- 
Marco Gavanelli, Ph.D. in Computer Science
Dept of Engineering
University of Ferrara
http://www.ing.unife.it/docenti/MarcoGavanelli/
Received on Tue Feb 09 2010 - 11:06:29 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST