Please see http://www.jsoftware.com/papers/eem/gcd.htm

To understand GCD/LCM, it's best to work with integers
and rationals first, before venturing into the domain
of dodgy floating point numbers.  The latter redefines
in subtle ways terms like "equal", "integer", etc. involved 
in the definition of GCD/LCM.

Puzzle:  How do you get the numerator and the denominator
of a rational number, if you did not have 2&x:?  For example:

   x=: (+%)/ 70$1r1
   x
308061521170129r190392490709135

Spoiler below.














   x
308061521170129r190392490709135
   1 +. x
1r190392490709135
   x % 1 +. x
308061521170129
   % 1 +. x
190392490709135



----- Original Message -----
From: Boyko Bantchev <[email protected]>
Date: Monday, July 25, 2011 9:01
Subject: Re: [Jprogramming] definition of +.
To: Programming forum <[email protected]>

> On 25 July 2011 16:57, Devon McCormick <[email protected]> wrote:
> > Based on a quick test, it looks like it gives a result 
> consistent with the
> > integer definition of GCD: if you divide both terms by the 
> answer, you get
> > integer results:
> > ................
> >   gcdDivBy=: 4 : '(x;y)%&><x +. y'
> > ................
> >   3 4 5 gcdDivBy 12.25
> > 12 16 20
> > 49 49 49
> 
> However, with `more real' real numbers:
> 
>    1p1 gcdDivBy 1p2
> 4.92635e11 1.54766e12
> 
>    x: 1p1 gcdDivBy 1p2
> 8867428937083r18 7738291556936r5

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to