Subject: Re: comparison tol. barrier in J?
From: Ian Shannon <ishannon@airmoon.epa.nsw.gov.au>
Date: Thu, 18 May 1995 11:49:47 +1000
References: <199505070715.AA15329@yrloc2.tor.soliton.com> <1995May8.102427.21314@jarvis.cs.toronto.edu>

0.	I know this might be a bit late but we are behind a fire wall and
for some reason it insists on delaying mail about 7 to 10 days.  (the
people responsible have fixed it up but it reverts to it usual behaviour
within a short time!

1.	Again for the fire wall reason not all my newsgroup posts get
out. (though all e-mail seams to get out).  So please respond, that way I
know I am communication with > 1 person!!

2.	{quad}CT in APL2/PC

------------------------------
      {quad}CT{assign}1E{neg}4
      =/10000 10001
0
      =/10{times}10000 10001
1
      =/3{times}10000 10001
0
      =/4{times}10000 10001
1

	Any number which is known to be an integer and is in the range
[-32768 32767] is stored as a 2 byte integer on APL2/PC, (except binary 0,
1) and as has been pointed out i1 = i2 should be 0 (regardless of
{quad}CT) if i1 and i2 are not the same.  Numbers > 32767 are stored as
floating pt so hence {quad}CT is used even though we know that the numbers
are integer.

      =/32766 32767
0
      =/1+32766 32767
1

farewell
ian

Ian Shannon, Metropolitan Air Quality Study
Environment Protection Authority NSW (EPANSW)
66 Rickard Road          ph:     +61 2 795-5059
Bankstown, NSW 2200      Fax:    +61 2 649 8768
Australia                email:  ishannon@airmoon.epa.nsw.gov.au
    Pythagorus was one side short of a square.

On 8 May 1995, Robert Bernecky wrote:

> In article <199505070715.AA15329@yrloc2.tor.soliton.com> Roger Hui <hui@Soliton.COM> writes:
> >
> >
> >It is reasonable that the system should impose such a limit to
> >make the normal comparisons faster (equal, not equal, less than,
> >etc. as well as index of, membership, etc.); it is easy enough to
> >effect comparsions using a tolerance larger than normal using the
> >following definitions (from Chapter 7 of "An Implementation of J"):
>
> The idea in every APL interpreter I have worked on is to ensure
> that i1=i2 returns a zero if i1-i2 is nonzero. That is, integers
> never compare equal. This is done primarily for interpreter performance
> reasons, with implementer sanity as a secondary concern.
>
....
>
> >ps. In TryAPL2, when {quad}ct is 1e_5, 100000=100001 is 1, but when
> >{quad}ct is 1e_4, 10000=10001 is 0.  I am puzzled by these results.
> >The first result seems to imply that the defn used is:
> >
> >   a teq b   <->   (|a-b) < {quad}ct {times} (|a) {max} |b
>
> This is indeed the ISO definition of tolerant comparison. However,
> some APLs do not implement it honestly, and use something of the
> form:
>    a. Do an unnormalized substract of the absolute values of the
>       numbers.
>    b. If the only remaining bits in the mantissa left on are
>       way over on the right [low-order end], call the numbers equal.
>
> This is faster on some old-timey computers, and is considered an
> important optimization by implementers who consider performance
> more important than correct answers.
>
> I don't know what APL2 does internally. Perhaps one of the IBMers
> can answer.
>
> Bob
