ANN: mxNumber -- Experimental Number Types, Version 0.2.0

M.-A. Lemburg mal at lemburg.com
Fri Apr 27 09:09:58 EDT 2001


Carlos Ribeiro wrote:
> 
> At 23:15 25/04/01 +0200, M.-A. Lemburg wrote:
> >Complex numbers are not integrated into the picture since I
> >think that they should not be auto-coerced.
> 
> What is the type of the real and imaginary terms of a complex number? Are
> they floats today?

For the C implementation of complex numbers, they are two C doubles 
today. The original Python implementation however 
(Demo/classes/Complex.py) does not seem to care about the types.

> It should be possible to specify a complex number with
> rational terms, don't you think?

Sure, why not ?!
 
> >   - there is no way to bind the types to a Python literal, e.g.
> >     by specifying a number literal modifier which is then bound
> >     to the type: 1234L -> long("1234"), 1234.123F -> Float("1234.123"),
> >     2R / 3 -> Rational(2, 3) etc.
> 
> An optional (and unambiguous) way to specify a Rational literal would be
> 
>    2R3   or   2r3
> 
> Some people may argue that its ugly. Note that I am not proposing that R
> should be trated as an operator; it's just like the "." (dot) in floats, or
> the "E" of the exponential notation. So the same rules apply - it's going
> to be handled by the parser, and there should be no spaces between the numbers.
> 
> WARNING: This is just a weird idea, but I think it's worth some
> investigation. It's very common to have mathematical constructs such as
> pi/4. Should these constructs be treated as "extended rationals"? It would
> allow for a much easier way to expresse some useful numbers. I don't think
> that this would be easy to handle, but anyway I'm curious about it...

The 'r' notation looks weird. About the handling of common terms
such as pi/4 -- well these are irrational numbers, so I guess the
only possible way to deal with them is by using arbitrary precision
generators... I don't think it is worth going down that lane though.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/




More information about the Python-list mailing list