Roger Hui wrote:
> By the way, to see the beneficial effects of tolerance,
> try doing without:
>
> gcd0=: {: @ (|!.0/\@|.^:(0~:{.)^:_) @ , " 0
> 0.03 gcd0 0.07
> 2.77556e_17
>
>
>
I realized there had to be something like this.
After looking at the 4*!19 stuff I became amazed that {: 2 x: 1%y was y so
often. I then reasoned:
Every 64-bit IEEE floating point number is really a fraction f=p/q where p
and q are integers, and q is a power of 2. So x: f should be
(p,q)%(p+.q), except that you will get some horrendous fractions.
If you take 1%3, the representing fraction f cannot have q=3*p. Instead
you have got to have either q=3*p+1 or q=3*p-1, even though you really
want p=p+.q. So you want to regard q=3*p provided 1%p (or 1%q) is 0 in
some tolerant way.
Best wishes,
John
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm