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

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Jul 30 02:09:11 EDT 2001


Mon, 30 Jul 2001 04:52:53 GMT, Bengt Richter <bokr at accessone.com> pisze:

> I think several notions of exactness are getting mixed.
> 
> Two relationships need to be separated:
> 1. bit pattern representing a number <-> *mathematical value*
> 2. *mathematical value* <-> significance in problem domain

I disagree. The only interesting relationship is
  number which can be represented in a bit pattern <->
  significance in problem domain.

The number represented can differ much from the number intended
because some operations (e.g. subtraction of positive numbers) may
make the result very inexact.

Which mathematical value are you talking about? The one represented
by the bit pattern or the one which would be used if arithmetic was
exact (assuming that it's a rational number at all)? In any case it
boils down to the above relationship.

> Exactness has to do with the first relationship. A particular bit
> pattern representing a number uniquely identifies its corresponding
> *mathematical value* by design. If the *mathematical value* is exactly
> what you want, declare the representation exact,

It's not useful to tag exact float values. Exactness depends on
artificial conditions. Operations on them don't always produce exact
results.

In effect sometimes by accident you might get an exact result, but
it's not guaranteed that the same computation of different data will
give an exact result. It's better to statically known that results
of a computation are not exact in general.

If you want exact results, simply don't use floats. If you don't
need exactness and know that the algorithm behaves well numerically,
use floats for speed. I don't see the point in the compiler inferring
whether it managed to get a particular result exact or not.

Not to mention that it's inefficient to check whether operations on
floats preserved exactness, so you hurt those who don't need exactness.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list