Hi Fred,
I did a small rework of the monadic *! *function. It should now be
exact (well, as exact as *×/⍳N* is) for integer arguments up to 170
(i.e. the max integer before DOMAIN ERROR is thrown),
Before it was calling *tgamma()* of *libm*.
There are still many cases where GNU APL calls *libm* functions
and replacing them all by more exact versions would be rather tedious.
There are often speed-precision trade-offs involved. Normally the
precision of *libm* functions is good enough. Let's fix issues on a
case-by-case basis when we find them.
/// Jürgen
On 08/06/2014 03:06 AM, Frederick H. Pitts wrote:
Gentle people,
Please find attached binom.apl.tgz. It contains the source for BINOM,
a defined function does what the primitive dyadic ! function does but
produces exact results over a larger range.
BINOM produces 1) the same results as ! over the range where !
produces exact integers, 2) exact integer results in range above that
produced by the ! but below the 9200000000000000000 upper limit of GNU
64-bit integers and 3) floating point results that match those of !
above the 64-bit integer upper limit.
In the interest of full disclosure:
1) The code is slow; 100 times slower than the primitive dyadic !. But
then BINOM is interpreted while ! is compiled in to the interpreter.
2) The code was presented in 1996 on comp.lang.apl by Jim Weigang and
others.
Enjoy,
Fred
Retired Chemical Engineer