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

Re: Exactness

This page is part of the web mail archives of SRFI 77 from before July 7th, 2015. The new archives for SRFI 77 contain all messages, not just those from before July 7th, 2015.



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

> I want to make more predictable when the programmer will obtain a
> ratnum and when a flonum. And I want him to be sure that he will not
> obtain some weird representation like "a ratnum with inexactness bit"
> or "fixed-size decimal fraction" without explicitly asking for it.

How about providing arithmetic functions that provide those guarantees
then?  

You're approach has been to have programmers ask for a particular
*implementation*.  This is not the scheme way, and it's a bad way to
think about programming in general.  Much better is to think about
what *features* specifically you want, and have programmers ask for
*those*.  It is in that sense that I say that Scheme does not have a
"flonum".

So far you've mentioned one feature: constant size arithmetic.  I've
suggested one way of having programmers ask for that feature (though
there are surely others).

>> See, this is where you're wrong.  Constant-width addition is valuable
>> for integers too, not just floats.  But when people doing integer
>> arithmetic want that, it's an "efficiency hack", and when you want it
>> for floating point, it's Absolutely Essential.
>
> What do you mean by constant-width addition?

I mean "addition in which the space use of the output is no larger
than the input".  This is a feature which you said was needed for
reals (I agree) and it's a feature that is useful for integers too. 

> Fixed-size floating point arithmetic differs in that it's safe, that
> people expect it to be slightly inexact (or should be taught to expect
> this), and that often the performance difference between fixed size
> floating point and exact ratios is huge, while the difference in the
> answer is small.

I don't know what you mean by "safe"; there are legions of programmers
making bad mistakes because of the unobvious intricacies of the way
that floating point simulates well understood mathematical
operations.

> Of course the programmer can use exact ratios instead if he chooses.
> It should be his choice, not the Scheme implementor's choice.

But it already is!  I'm baffled by what you're asking here; the
feature you seem to be requesting (though I can't tell for sure) is
now that you want a way for programmers to specify whether they want
exact or inexact numbers.  Of course, Scheme provides that already.

> Letting (+ 1.2 3.4) perform fixed-size binary floating point arithmetic
> is compatible with both the existing standard and common practice.

What exactly are you asking for?  Perhaps I'm misunderstanding.  

By "letting" do you mean "requiring"?  (Because then, you're wrong.)