[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exactness



Marcin 'Qrczak' Kowalczyk <qrczak@xxxxxxxxxx> writes:

> I know what to expect from IEEE floats. I know for example that
> calculations in a certain range of integers are exact. Or that numbers
> have the same relative precision but different absolute precision, for
> a wide range of magnitudes. Or that certain primitive operations take
> constant time, and a number uses a fixed amount of memory - it doesn't
> keep growing precision. I should be able to know more in Scheme - for
> example that by default a flonum overflow will not be fatal but will
> yield +inf.0, which will compare as greater than any other number
> except itself and +nan.0.
>
> I know what to expect from ratios.
>
> I don't know what to expect from inexact real numbers. Do they behave
> like floats, or like ratios with inexactness bit? It does matter!

So we need a way to query those questions.  Scheme doesn't have
"flonums" and that's a good and rational design choice.  We don't want
to bundle extra meaning in with "inexact real", and start making
guarantees about them which have nothing to do with real or exact, but
are simply artifacts of traditional implementations.

But what you want is still sensible, of course.  It's not a property
of a value that it has a fixed size (after all *all* values, all
bignums have a fixed size).  That's a property of *operations*, as
your language suggests.

So if you want an implementation of + that is guaranteed not to use
more memory in the result than in the operands, we can have that.  No
problem.  Such a function should also have optional arguments that
specify what happens if the result doesn't fit in the space needed.

Thomas