I sometimes had to compensate for cumulative tolerance(s) by using some 
algo like the one described in:
"What Every Computer Scientist Should Know About Floating-Point 
Arithmetic"
Where the iso-8859-1 algo is described. I translated (in a naive way) my 
APL code to J and it gives:

sum=: 3 : 0
(_1{.t)++/}.y.-t-_1|.t=.+/\y.
)

I then built a vector of numbers like:
v=:1e6*1e6?1e8
then I applied the primitive +/ and the defined sum using x:
   x: +/v
50080212263674585088
   x: sum v
50080212263676002304

Then, something we can do in J I could not do in APL:
   +/x: v 
50080212263676000000

Conclusion: In 32 years, I had to use it once but it's nice to know...

Paul Gauthier
APL Software Developer - Senior
[EMAIL PROTECTED]
Phone: 312-739-3467
Fax: 312-739-3496

CheckFree. The Company that Powers Payment on the WebSM.
http://www.checkfree.com/paybillsonline




Eugene McDonnell <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED]
05/31/2006 11:34 AM
Please respond to
Programming forum <[email protected]>


To
Programming forum <[email protected]>
cc

Subject
Re: [Jprogramming] Equal tolerence







On May 31, 2006, at 9:01 AM, Ralph G Selfridge wrote:

> The sort of crazy results you can get if tolerence is not 
> identically zero
> is a squence of numbers, each of which 'equals' its neighbours but the
> first and last are not equal.

Paul Berry tells this story:

In an early talk Ken was explaining the advantages of tolerant 
comparison. A member of the audience asked incredulously, ?Surely you 
don?t mean that when A=B and B=C, A may not equal C?? Without 
skipping a beat, Ken replied, ?Any carpenter knows that!? and went on 
to the next 
question.----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to