[Python-ideas] complex number and fractional exponent (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sat Jan 26 16:01:31 CET 2013
- Previous message: [Python-ideas] complex number and fractional exponent
- Next message: [Python-ideas] complex number and fractional exponent
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Jan 26, 2013 at 10:01 PM, Vito De Tullio <vito.detullio at gmail.com> wrote:
There is some ideas about extending the pow() / ** operator to return complex number when necessary?
ATM I don't need to work with complex numbers, nor I have strong opinion on the choice, it's more that I'm curious on why was introduced a so big language difference on division and not extended to power exponentiation.
Python 3.2.3 (default, Jun 8 2012, 05:36:09) [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
(-1) ** 0.5 (6.123031769111886e-17+1j) pow(-1, 0.5) (6.123031769111886e-17+1j)
The math module is still deliberately restricted to float results, though, as that module is intended to be a reasonably thin wrapper around the platform floating point support. The cmath module and the builtin pow are available if support for complex results is needed.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-ideas] complex number and fractional exponent
- Next message: [Python-ideas] complex number and fractional exponent
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]