proposed language change to int/int==float (was: PEP0238 lament)

Bengt Richter bokr at accessone.com
Mon Jul 30 17:06:41 EDT 2001


On Mon, 30 Jul 2001 02:22:21 -0400, "Tim Peters" <tim.one at home.com> wrote:
[...]
>IMO, so long as we've got internal numeric representations on the brain,
>Scheme's model makes little sense -- the point of Scheme's model was to get
>away from representations and move toward abstract mathematical values.
>
>That said, you may get to the same result in the end in this case anyway,
>thanks to the contagiousness of inexactness (but not of *type*!):
>
>> (integer? (floor (/ 20. 2)))
>#t
>> (exact? (floor (/ 20. 2)))
>#f
>>
>
I suspect they have chosen to coerce exact to #f whenever they internally
use floating point. Either that, or you have a version like my old pc scheme
that doesn't implement exact?

>So 20.//2 is not usable as a sequence index in Scheme, despite that "it's an
>integer" (as Scheme means "an integer").  Python can get to the same place
>in the end, but the terminological battle on the way there is going to be
>excruciating.
>
Yes, it's really hard to communicate thoughts about these things.
Is there a standard glossary we can all refer to?

For floating point unit terminology, probably
    http://www.cs.berkeley.edu/~wkahan/ieee754status/Names.pdf
but there's a lot of terms flying around. Does O'Reilly put out a
programmer's math dictionary? It'd be nice as a mini-book.

I would like it if Python could do better than Scheme. IMHO they compromised
badly if
    (exact? 2) => #t
and
    (exact? 2.0) => #f

If the above is so, they're hiding something with a pretty thin veil ;-)

You would know how much floating point there is in the interpreter, I assume ;-)
What's the chance of rewriting it to take advantage of IEE754's fpu precision status bit?

(Not to mention opportunities that would arise at the same time to provide access to
other controls and status such as rounding mode, etc.).

I think it could be a competitive advantage and distiction for Python to use IEE754 well.
It would also probably please Prof. Kahan, don't you think?

---
BTW, in
    http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf
he said about Java (excerpt):

"4. Every programmer’s prospects for success are diminished by Java’s refusal to grant access
to capabilities built into over 95% of today's floating-point hardware.
5. Java has rejected even mildly disciplined infix operator overloading, without which extensions
to arithmetic with everyday mathematical types like complex numbers, intervals, matrices,
geometrical objects and arbitrarily high precision become extremely inconvenient."

He also said, "Many people still think Floating-Point is a Black Art. They are wrong too."
Easy for him to say ;-)

Glad I finally picked up on the mention of Kahan and googled.
It might even change my misgivings about -0 ;-)




More information about the Python-list mailing list