[comp.lang.apl] Factorials in J

simpson@aplcen.apl.jhu.edu (Simpson David Grant) (03/09/91)

Can someone explain what is happening when I try to calculate
factorials in the following J session?  I do this right after
starting up J (version 3):

   !9
362880
   !174
1.7=e309
   !9
1

All following attempts to calculate factorials also produce 1.
What gives?

                                 David Simpson

sam@kalessin.jpl.nasa.gov (Sam Sirlin) (03/12/91)

In article <1991Mar9.040541.28914@aplcen.apl.jhu.edu>, simpson@aplcen.apl.jhu.edu (Simpson David Grant) writes:
|> In article <1991Mar9.040541.28914@aplcen.apl.jhu.edu>, simpson@aplcen.apl.jhu.edu (Simpson David Grant) writes:
|> 
|> Can someone explain what is happening when I try to calculate
|> factorials in the following J session?  I do this right after
|> starting up J (version 3):
|> 
|>    !9
|> 362880
|>    !174
|> 1.7=e309
|>    !9
|> 1
|> 
|> All following attempts to calculate factorials also produce 1.
|> What gives?
|> 
|>                                  David Simpson

What version/machine? With 2.9 on my SPARC 1 I get:


   !9
362880
   !174
_
   !9
362880
   !4
24


which looks fine. Version 2.4 on my PCAT bombs when it trys !174 (overflow). 
Sounds like infinity doesn't quite work in your version.

-- 
Sam Sirlin
Jet Propulsion Laboratory         sam@kalessin.jpl.nasa.gov

simpson@aplcen.apl.jhu.edu (Simpson David Grant) (03/13/91)

>|> In article <1991Mar9.040541.28914@aplcen.apl.jhu.edu>, simpson@aplcen.apl.jhu.edu (Simpson David Grant) writes:
>|> 
>|> Can someone explain what is happening when I try to calculate
>|> factorials in the following J session?  I do this right after
>|> starting up J (version 3):
>|> 
>|>    !9
>|> 362880
>|>    !174
>|> 1.7=e309
>|>    !9
>|> 1

>|> All following attempts to calculate factorials also produce 1.
>|> What gives?
>|> 
I got these results with J version 3 for the PC, running on my
Zeos 386.  I tried this same software today on an IBM AT (80286)
with different results -- it hangs the computer for !174, but 
does not answer "1" for every factorial like my 386 does.

                                    David Simpson 

sam@kalessin.jpl.nasa.gov (Sam Sirlin) (03/14/91)

In article <1991Mar13.042856.23984@aplcen.apl.jhu.edu>, simpson@aplcen.apl.jhu.edu (Simpson David Grant) writes:

|> I got these results with J version 3 for the PC, running on my
|> Zeos 386.  I tried this same software today on an IBM AT (80286)
|> with different results -- it hangs the computer for !174, but 
|> does not answer "1" for every factorial like my 386 does.
|> 

I tried this in version 2.9 on IBM PCAT and Everex 386. The pc version 
of 2.9 doesn't have infinity, and both machines give domain errors for  
factorial arguments > 170, but work fine afterwards. Maybe you should 
grab 2.9 from watserv. The sun4 version of 2.9 seems to have a limited 
implementation of infinity.

-- 
Sam Sirlin
Jet Propulsion Laboratory         sam@kalessin.jpl.nasa.gov

hui@yrloc.ipsa.reuter.COM (Roger Hui) (03/19/91)

_ (infinity) is not yet available, and this is indicated as 
such in the status.doc file.  It is not yet available because 
(a) the implications of _ are pervasive and (b) there is uneven
hardware and C compiler support for _.  

Nevertheless, !174 should have failed more gracefully than it did.
If you'd tell me the machine and the J version, it would help me
a great deal in tracking down this error.  (J runs on over a dozen 
different machines.  On a given error, the possibilities are numerous:
it happens on all versions; it happens on only some machines; it is
my error; it is a C compiler bug; etc. etc. etc.)

Roger Hui
Iverson Software Inc., 33 Major Street, Toronto, Ontario  M5S 2K9
(416) 925 6096