It is a direct consequence of the definition of tolerant equality that comparisons with 0 are not tolerant:
x=!.t y if (|x-y)<:t*x>.&|y definition of tolerant = 0=!.t y if (|0-y)<:t*0>.&|y substitute 0 for x 0=!.t y if (|y)<:t*|y algebra So if t<1 (which t is required to be), y must be 0. See also the essay in the J Wiki: http://www.jsoftware.com/jwiki/Essays/Tolerant_Comparison which among other things demonstrates that t>:1 gives nonsense results. ----- Original Message ----- From: "Oleg Kobchenko" <[EMAIL PROTECTED]> To: "Programming forum" <[email protected]> Sent: Sunday, May 28, 2006 10:08 PM Subject: [Jprogramming] Equal tolerance fit conjunction -- again I need to compare floats (complex) with more lenient tolerance, that is numbers a bit farther apart would return equal. In particular, I need to compare with 0, so that for 0e_11 it returns 1 and for 0e_9 it returns 0. >From the dictionary, http://www.jsoftware.com/books/help/dictionary/d000.htm "comparison is made with a tolerance t , normally 2 to the power _44". But 0 = 2^_44 0 0 = 2^_60 0 0 = 2^_20 0 So how does this example relate to the rule above? It continues, "but also controlled by the fit conjunction !. , as in x=!.0 y . Formally, x=y is 1 if the magnitude of x-y does not exceed t times the larger of the magnitudes of x and y ." With zero and positive x we have (|x-0) <: t*x x <: t*x 1 <: t This doesn't make sense. Can I compare tolerantly with zero at all? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
