(in)exactness of complex numbers

David C. Ullrich ullrich at math.okstate.edu
Sat Jul 28 10:37:08 EDT 2001


On Fri, 27 Jul 2001 18:01:36 GMT, Guido van Rossum <guido at python.org>
wrote:

>Skip Montanaro <skip at pobox.com> writes:
>
>> Once these numeric changes are all implemented, if I define a complex
>> constant with either integer real or imaginary parts, e.g.
>>     
>>     c = 1+2.1j
>> 
>>     d = 1.2+5j
>> 
>>     e = 4+7j
>> 
>> should I get an integer back (exact) or a float (inexact) when asking for an
>> attribute that was originally an integer?  In general, can complex numbers
>> be considered to have two exactness attributes?
>
>That's probably not worth the implementation complexity.  I expect
>that all floats and complex will be considered inexact, and all
>rationals and ints exact.  That seems to be the most practical set of
>rules, even if it doesn't satisfy everybody.

Again, don't get the idea I'm actually saying you should worry about
this. But it looks to me like you've missed the point - at least
it looks to me like you've missed what it seems to me the point is:

If all floats are inexact and ints and rationals are exact fine. 
But why should the real and imag of a complex be required to be 
floats in the first place? Why  shouldn't they be allowed to be 
floats or rationals or integers?

(Of course that would complicate things, which is why I'm not
saying this is how it should be. But I don't think the people
talking about complexes being either exact or not are 
necessarily disputing the idea that ints and rationals should
be exact and floats should be inexact. Surely a vector class
or a matrix class should allow the entries to be of various
types, why shouldn't complexes?)

>--Guido van Rossum (home page: http://www.python.org/~guido/)


David C. Ullrich



More information about the Python-list mailing list