From: Dave Yost
Subject: why no big-float?
Date: 
Message-ID: <-0904960524410001@mac1.yost.com>
We have bignum.  Why don't we have big-float?

Recently I was working a problem of probabilities
and resorted to using logarithms for speed of execution.
Problem was that I ended up with a logarithm that was too
big to be represented in floating point.  My solution was
to do convert all logarithms to (large) integers, do the
calculation, then convert back to log.

This suggests an implementation for big-float: use bignums
with a (settable) scale factor (which corresponds to precision).

Has anyone implemented big-float?

Dave

-- 
Dave Yost
    @    .com

From: Erik Naggum
Subject: Re: why no big-float?
Date: 
Message-ID: <3038075592819373@arcana.naggum.no>
[Dave Yost]

|   We have bignum.  Why don't we have big-float?
:
|   Has anyone implemented big-float?

CLISP has this.

$ clisp

> (list (lisp-implementation-type) (lisp-implementation-version))
("CLISP" "1996-03-15 (March 1996)")
> (/ 7l0)
0.14285714285714285714L0
> (float-digits *)
64
> (setf (long-float-digits) 128)
128
> (/ 7l0)
0.142857142857142857142857142857142857143L0
> (float-digits *)
128
> (quit)

it is not exactly well documented, but pretty much what you outlined.

#<Erik>
-- 
education is for people who can't handle reality the hard way
From: Bruno Haible
Subject: Re: why no big-float?
Date: 
Message-ID: <4kmebv$s4f@nz12.rz.uni-karlsruhe.de>
[Dave Yost]
>|   Has anyone implemented big-float?

[Erik Naggum]
> CLISP has this.

Other Common Lisp implementations can get this feature as well. CLISP's
bignum and bigfloat library is now available as a separate package,
a library which was put together with the intent of being incorporated
into Lisp implementations and math packages.
ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/gnu/cln.tar.z. `cln' stands
for "Common Lisp Numbers".

> > (setf (long-float-digits) 128)
> 128
> > (/ 7l0)
> 0.142857142857142857142857142857142857143L0

This is easy. The "hard" stuff are the transcendental functions:

> (setf (long-float-digits) 1024)
1024
> (- (+ (/ (sin (* 2/7 pi))) (/ (sin (* 4/7 pi)))) (/ (sin (* 6/7 pi))))
-2.225073858507201383090232717332404064219215980462331830553327416887204434
813918195854283159012511020564067339731035811005152434161553460108856012385
377718821130777993532002330479610147442583636071921565046942503734208375250
806650616658158948720491179968591639648500635908770118304874799780887753749
94945158045L-308

(Btw: Can any symbolic computer algebra system prove that the exact value
of sin(2/7*pi)^-1 + sin(4/7*pi)^-1 - sin(6/7*pi)^-1 is zero?)


Bruno Haible                                     email: <······@ilog.fr>
Software Engineer                                phone: +33-1-49083585
From: Richard J. Fateman
Subject: Re: why no big-float?
Date: 
Message-ID: <4kmqvo$3eu@agate.berkeley.edu>
In article <··········@nz12.rz.uni-karlsruhe.de>,
Bruno Haible <······@ilog.fr> wrote:
>[Dave Yost]
>>|   Has anyone implemented big-float?
>
>[Erik Naggum]
>> CLISP has this.
>
>Other Common Lisp implementations can get this feature as well. CLISP's
>bignum and bigfloat library is now available as a separate package,
>a library which was put together with the intent of being incorporated
>into Lisp implementations and math packages.
>ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/gnu/cln.tar.z. `cln' stands
>for "Common Lisp Numbers".

There are big-float implementations on top of lisp in Macsyma
(There is a paper on Macsyma's implementation Proc. of 1776 Symsac conf.),
Reduce,MockMMA (available free from me), also.
I have also implemented an interface from AllegroCL to David Bailey's
state-of-the-art fpfun package, which is quite fast and includes 
not only the usual transcendental functions but a set of other
number-theoretic bignum facilities. He has both fft-based and conventional
multiplication.
Instead of building on top of bignums (integers), he uses arrays of
IEEE floats.  Yes, the exponent space is wasted. The speed is much
improved, and on many computers these days can be parallelized 
explicitly or even automatically the presence of multiple arithmetic units.

-- 
Richard J. Fateman
·······@cs.berkeley.edu   http://http.cs.berkeley.edu/~fateman/
From: William D. Gooch
Subject: Re: why no big-float?
Date: 
Message-ID: <goochb.323.001151BF@rwi.com>
In article <·················@mac1.yost.com> ····@Yost.com (Dave Yost) writes:

>We have bignum.  Why don't we have big-float?
>....
>This suggests an implementation for big-float: use bignums
>with a (settable) scale factor (which corresponds to precision).

That sounds like a rational, which "we do have," yes?

Floats are basicaly for speed, not high precision.

~~~~~~~~~~~~~~~~~~~~~~
William D. Gooch
RothWell International
······@rwi.com
Texas liaison for the International Programmers Guild
For information on IPG, see http://www.ipgnet.com/ipghome.htm
~~~~~~~~~~~~~~~~~~~~~~
From: Erik Naggum
Subject: Re: why no big-float?
Date: 
Message-ID: <3038081912827191@arcana.naggum.no>
[William D. Gooch]

|   Floats are basicaly for speed, not high precision.

but transcendental functions are usually implemented with floats, even
though most of them can be computed with rationals in series.  this means
that we lose precision in converting from rational to float, and may run
into Dave's original question.  on the other hand, using series to compute
transcendental functions on rationals will require a "cut-off" after a
given precision is reached.  at this point, we might as well implement
"bigflos", and Bruno Haible's CLISP already does that.  unfortunately,
CLISP is byte-compiled and not particularly fast.  it's a tough choice.

(incidentally, several packages exist for C to achieve multiprecision
arithmetic.  they are not very easy to work with.  I think CLISP has done
the right thing when using one such package for Lisp's long float.)

#<Erik>
-- 
education is for people who can't handle reality the hard way