On 10/21/2012 09:35 PM, Steven D'Aprano wrote: > so as far as I can tell, the only way you could accidentally get a > complex number without expecting one is by exponentiation, either by ** > or the builtin pow. This includes square roots. Exponentiation isn't as > common as the basic four arithmetic operators, but it is hardly exotic. > > Any time you have a non-integer power and a negative base, you will get > a complex number. No, only via the builtin pow. % python3 Python 3.3.0 (default, Sep 29 2012, 22:42:55) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import math >>> pow(-1, 0.5) (6.123031769111886e-17+1j) >>> -1 ** 0.5 -1.0 >>> math.pow(-1, 0.5) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: math domain error >>> //arry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20121022/e220509c/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4