Actually, J has extended precision integers and
rational numbers.  With rational numbers it is 
possible to compute various functions to arbitrary 
precision.  See for example:
http://www.jsoftware.com/jwiki/Essays/Extended_Precision_Functions

Introducing into J arbitrary precision floating 
numbers (big floats, BF) would be non-trivial,
but easier than the impression that Devon gives.  
Each BF (or all BFs globally) would include an 
indication of how many digits of precision are 
represented.  So the abstract number 1%3 to 30 
decimal digits would be
   0.333333333333333333333333333333
and 250 to the same number of digits would be
   250.000000000000000000000000000

Suppose BF were implemented in J.  If x is the
first BF above and y is the second, then you
should be able to do:

   x * y
83.3333333333333333333333333333
   x - y
_249.666666666666666666666666667
   ^. y
5.52146091786224643321951012114
   ^ y
3.74645461450267326034995481220e108

Algorithms would have to be found for all the
different primitives (as in the essay).  
%. and H. should be interesting.


--------------------------------------------

>From   Devon McCormick <[EMAIL PROTECTED]> 
Sent    Monday, February 26, 2007 9:10 am
To      Programming forum <programming@jsoftware.com> 
Subject         Re: [Jprogramming] Lack of Precision?

Geoff -

J's extended precision applies to integers only.  If you think about it,
you'll see
that while it's relatively simple to make integers arbitrarily large,
floating point
is a much more difficult proposition: how would you know when to stop
in the potentially infinite expansion of a floating point number?  Even
something
as simple as %3 is a problem.

This restriction to integers is why something like Ahmad's
<[EMAIL PROTECTED]: 2x*10x^200
works: "<[EMAIL PROTECTED]:" applies both the square root and enforces the
integer limitation at the same time.

On 2/26/07, Geoff Canyon <[EMAIL PROTECTED]> wrote:
>
> (this is my first J code)
>
> I'm executing this to get the square root of 2:
>
> x:%:x:2e100
>
> I also tried:
>
> <.((%:2)*10^100)
>
> In both cases I'm looking for extended precision (100 places if J
> supports it).
>
> In both cases it appears the digits take a left turn about 20 digits
> in -- they don't match publicly available resources on the web.
>
> Is there something else I should be doing, or is there a limit to J's
> precision?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to