[Jprogramming] Tolerant Equality

Roger Hui rhui000 at shaw.ca
Sun Oct 29 00:08:37 HKT 2006


Please see http://www.jsoftware.com/jwiki/Essays/Tolerant_Comparison



----- Original Message -----
From: "Leigh J. Halliwell" <leigh at lhalliwell.com>
Date: Saturday, October 28, 2006 9:06 am
Subject: [Jprogramming] Tolerant Equality

> Dear J Forum:
> 
> What are the limits to the domain of t?  See the examples below, where
> sometimes tolerant equality works and sometimes it doesn't.  I 
> would like
> for J to consider numbers tolerably equal if they match to a few 
> decimaldigits.  Can I do this with the !. adverb, or must I resort 
> to rounding the
> numbers?
> 
>   t =. 0
>   1 (=!.t) 1.0000001
> 0
> 
>   t =. 0.001
>   1 (=!.t) 1.0000001
> |domain error
> |   1(    =!.t)1
> 
>   t =. 2^_35
>   1 (=!.t) 1.0000001
> 0
> 
>   t =. 2^_15
>   1 (=!.t) 1.0000001
> |domain error
> |   1(    =!.t)1




More information about the Programming mailing list