HELP: restore my faith in Python

Tim Peters tim_one at email.msn.com
Sat Mar 4 20:29:04 EST 2000


[Tim Peters]
> At the level of the original poster's question, the best IEEE-754
> conformant answer is "floating point sucks".

[Moshe Zadka]
> That's it. I've given up on trying to understand you.

Then you're close <0.9 wink>.  Actually, I believe you understand me fine,
you'd just rather not believe it:  floating point sucks, rationals suck,
refusing to allow int division sucks, the constructive reals suck, symbolic
manipulation sucks, ..., but all in different ways for different reasons.
Every one bristles with its own brands of both shallow and deep "surprises".
So it goes -- seeking to represent the infinite by the finite is an
inherently unreachable goal.  This is also why people die <wink>.

> What should 1/2 do?
>
> 1. It can't return 0.5 -- floating point sucks
> 2. It can't return Rational(1, 2) -- rational arithmetic blows up
> 3. It can't return 0 -- integer division is confusing
>
> (Note that I do agree on 1 and 3, and you managed to convince me about 2)

I think P3K should opt for #2, on the principle of least initial surprise.
You have to become an expert to deal with *any* of them if you're going to
proceed to non-trivial things, but #2 probably manages to hide that
unpleasant truth a little longer, and when it screws you it's for space/time
reasons rather than correctness ones.

> i-fear-the-decimal-point-ly y'rs, Z.

Your fear of the binary point is much deeper <wink>.

[and in another msg]
> until-the-timbot-implements-slash-arithmetic-for-intel-cpus-ly y'rs, Z.

[Patrick Phalen]
> That'll never happen ... doesn't fit the bot's oft-expressed Criterion
> of Uselessness. <wink>

No no, slash arithmetics are sufficiently useless for me!  They give the
illusion of not losing info in simple cases (1/3, 7/10), then suddenly lose
info as soon as the sum of the bitlengths of the numerator & denominator
"gets too big".  Their primary attraction is in making division as fast as
multiplication -- provided you have special HW support for fast GCD.  In the
absence of that, they make everything (much) slower than fp.  Surprising &
expensive isn't quite enough to make them attractive, but surprising in new
ways *nobody* is yet used to -- ahhhhh, that's what a bot lives for <wink>.

human-confusion-is-our-opportunity-to-conquer-ly y'rs  - tim






More information about the Python-list mailing list