[Curious] Integer division => fraction
Andreas Raab
andreas.raab at gmx.de
Thu Jun 12 15:13:35 UTC 2003
Stephen,
Interesting insight. Thanks for pointing this out.
Cheers,
- Andreas
> -----Original Message-----
> From: squeak-dev-bounces at lists.squeakfoundation.org
> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On
> Behalf Of Stephen Pair
> Sent: Thursday, June 12, 2003 4:11 PM
> To: The general-purpose Squeak developers list
> Subject: Re: [Curious] Integer division => fraction
>
>
> Andreas Raab wrote:
>
> >Hi Guys,
> >
> >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?
> >
>
> I think there are many applications that could be harmed by
> the loss of
> precision. If you need a float and are willing to deal with
> the loss of
> precision, it's better to be explicit about that (by sending
> #asFloat)
> than it is to implicitly lose precision at arbitrary places in a
> computation.
>
> I also don't think that most people find it confusing to get
> a fraction
> (at least not anyone familiar with object oriented programming and
> mathematics). What I think might actually be causing
> confusion is trying
> to think in terms of fractions...not the fact that the result is
> internally represented as a fraction.
>
> One thing that might alleviate some of this confusion is to have a
> preference that would cause fractions to be displayed as
> floats (in the
> inspectors for example)...I actually find myself sending #asFloat to
> fractions from time to time just to see a fraction in a
> floating point
> representation...its hard to digest big fractions like: "(
> 34123412341234124 / 14312431343 )"...it's much easier to think about
> this fraction as: 2384179.98476013. This is especially true
> when you're
> looking at multiple fractions and trying to guage their relative
> magnitudes when their reductions have different denominators.
>
> Unfortunately, there might be some unsuspecting and casual users of
> #printString that might get bitten if the preference were
> enabled. But,
> it couldn't hurt to try it...it would be interesting to see if the
> confusion is alleviated by simply changing the presentation of the
> fraction in some key places.
>
> - Stephen
>
>
>
>
More information about the Squeak-dev
mailing list
|