----- Original Message -----
From: "Roger Hui" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Thursday, February 07, 2008 3:11 PM
Subject: Re: [Jprogramming] Algorithm to represent floating point
numbersasfractions
pq=: 3 : 0
q=. <. 0.5 + % 1 +. y
p=. <. 0.5 + y * q
p,q
)
pq 0.625
5 8
pq 0.07
7 100
] y=: ? 0
0.536676
pq y
9.08637e12 1.69308e13
%/ pq y
0.536676
y - %/ pq y
_4.51861e_14
Note that +. (GCD) is tolerant. Depending on your needs you
may want to use +.!.0 (0 tolerance) instead of +. .
What are continuous fractions?
I used the term "continuous", for similarity with the Spanish one. This is a
valid name, but it is better known a "continued fractions". The following is
one of many links on the subject. I tried to get wikipedia's, but at this
moment wikipedia seems no to be working.
http://mathworld.wolfram.com/ContinuedFraction.html
Regards.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm