[Curious] Integer division => fraction
Alan Kay
Alan.Kay at squeakland.org
Thu Jun 12 05:38:33 UTC 2003
Floating point wasn't on the Alto, but I think that the motivation
was much more about how easy it was to create all the different
number systems including rationals in objects.
Also, I seem to recall (but not vividly) that since we could define
our fonts as we wished back then, we at some point used the other
division sign -- shown as a horizonal dash with a dot above and
below (it's very annoying that in 2003 I can't be sure that typing
this on my Mac will actually render correctly on everyone elses email
system) -- to mean "give me a float back regardless".
Cheers,
Alan
------
At 4:16 AM +0200 6/12/03, Andreas Raab wrote:
>Hi Dan,
>
>Thanks for this interesting response. One more question on "historical"
>grounds: I was wondering if there actually had been any (reasonably good)
>floating point point operations on the hardware you were dealing with. These
>days, floats are a zillion times faster to compute than fractions but this
>hasn't always been the case - so I wonder if "back then" fractional
>arithmetic was at essentially the same speed as floating point arithmetic
>(which, from my POV, would be a clear reason to use fractions instead of
>floats as you don't buy anything with floats in this case).
>
>Cheers,
> - Andreas
>
>PS. Of course what "most people" think is always hard to estimate - but
>that's exactly why I'm soliciting responses and both Johns and your reply
>give valuable insights ;-) I'm hoping for more.
>
>> -----Original Message-----
>> From: squeak-dev-bounces at lists.squeakfoundation.org
>> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On
>> Behalf Of Dan Ingalls
>> Sent: Thursday, June 12, 2003 3:39 AM
>> To: The general-purpose Squeak developers list
>> Subject: Re: [Curious] Integer division => fraction
>>
>>
>> "Andreas Raab" <andreas.raab at gmx.de> wrote...
>>
>> >Just had an interesting discussion with Dean (over on
>> e-Lang) about integer
>> >division semantics. He pointed out (and I agree) that most
>> people tend to
>> >find it it confusing that "3/4" results in a fraction rather
>> than coercing
>> >to Float by default.
>> >
>> >My questions: What do you think about this issue? Are you personally
>> >surprised if you get a fraction back? Has it bitten you in unexpected
>> >places? Have you actually ever had the need for coercing to fractions
>> >instead of floats? Can you think of "typical" applications
>> that would be
>> >harmed by coercing to floats?
>>
>> There is of course no assurance that a simple and consistent
>> design will be what "most people expect". I mean, most
>> people expect C or Java or Basic. That said, I think there
>> are interesting underlying issues here.
>>
>> I think I agree that "most people" think about arithmetic as
>> operator-based, and not as object-oriented (ie dependent on
>> who is receiving the message). This was NOT how we thought
>> about it when we first asked ourselves "Hmm, here we have a
>> world of objects; how should they behave" back in the early
>> 70's. In those days (for a while) 3 + 0.14 gave you a
>> different result from 0.14 + 3. This caused a LOT of
>> confusion, and so we introduced coercion. The current
>> coercion scheme fits pretty well with what "most people
>> expect" in spite of giving full receiver control over semantics.
>>
>> On the eve of the Smalltalk-80 release, we had a lot of
>> serious discussion about the various arithmetic operations --
>> integer division, real division, how modulo works with
>> negative numbers, etc., etc. While I participated, it was
>> others (Peter, Glenn, Ted, Adele, and anyone with traditional
>> math sensitivity) who made the final decisions on these. The
>> question here is one of definition. What does "/" mean? In
>> St-80 it is supposed to mean "exact" division, not "give me
>> the best you can" (except for Floats who can't do anything else ;-).
>>
>> However, I think that "most people" have come to accept "give
>> me the best you can" for "/" because "most systems" don't
> > offer fractions and so, in their own desire to approximate
>> what "most people expect" they deliver floating point results.
>>
>> Now, unfortunately IMO, for "most people" acceptance becomes
>> expectation (a human tendency), while the definition of "/"
>> in Smalltalk has not changed, and 355/113 is not pi, even
>> though in a lot of systems you might think so. That's the
>> purist perspective, which John Sarkela articulated in a lot
>> less words. I know the tension you feel, and yet I don't
>> think we have to feel ashamed of our position.
>>
>> Besides simply remembering and advertising that "/" means
>> exact division, there are a couple of other possibilities, of
>> course. One is to have a preference to print fractions as
>> floats. Another is to change "/" to mean produce a float.
>> If anyone opts for this, then I would certainly agitate for
>> SOME other operator that means exact division.
>>
>> I would be interested to hear what the MathMorphs folks would
>> have to say about this, or anyone familiar with, eg, MathLab
>> or the good Lisp math libraries.
>>
>> - Dan
>>
--
More information about the Squeak-dev
mailing list
|