On Numbers

Bengt Richter bokr at oz.net
Sun Jan 15 02:16:00 EST 2006

On Sat, 14 Jan 2006 18:18:12 -0500, Mike Meyer <mwm at mired.org> wrote:

>In the discussion of equality, the issue that decimal('3.0') == 3.0 is
>False came up as a reason for changing the behavior of ==. The problem
>with this is that the proposed change doesn't really fix anything, it
>just gives different wrong behavior. The correct fix would seem to be
>fixing python's handling of numbers.
>It's not clear from the PEP why test for equality always fails. While
>the PEP says that interactions with floats are disallowed as "to
>tricky", comparisons seem to be an exception. In particular, equality
>comparisons seem to always return false, whereas checking for
>magnitude seems to work.
>What appears to be missing in Python is a coherent model for all
>numberic types. Other languages have this, so there's no obvious
>reason that Python can't. Or maybe Python does, and I've overlooked
>it. In that case, pointers to documentation would be appreciated.
>If it doesn't exist, then I think this is something that should be
>addressed for Py3K.
>I'd like to work on that. The idea would be that all the numeric types
>are representations of reals with different properties that make them
>appropriate for different uses. The goal would be a model for a
>numeric type that captures those properties in a way that allows them
>to be combined to give sane behavior without being "to tricky".
>To get started on that, I want to consider how other languages with
>rich numeric type systems model them. I'm going to look at a couple of
>languages in the LISP family. I'd like to solicit the community for
>the names of languages (and pointers to references, if possible!) with
>a coherent view of a rich set of numeric types.
I suppose you have already found scheme's rsr5 spec, e.g.,

while thinking about numbers, the issue of equivalence that got us here
is also explored in scheme
and the section that follows in  on numbers

for common lisP
you can also chase lots of interesting links (some dead though) from
cltl2 is at

Now try to get some work done ;-)

BTW, IIRC Ada's numbers include some interesting provisions for representing numbers
in fixed point with specified fractional accuracy
I google and found
browsing a bit, scalar types are at
integers include unsigned by way of genera modular definition
and here is the fixed point
Whoo, I haven't been into that stuff almost since Ada was "green" ;-)
Makes me wonder if generators could usefully have rendezvous('?, es?) ;-)

Bengt Richter

More information about the Python-list mailing list