<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 10/21/2012 09:35 PM, Steven D'Aprano
wrote:<br>
</div>
<blockquote cite="mid:20121022043508.GC10202@ando" type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<br>
No, only via the builtin pow.<br>
<br>
<blockquote><tt>% python3</tt><tt><br>
</tt><tt>Python 3.3.0 (default, Sep 29 2012, 22:42:55) </tt><tt><br>
</tt><tt>[GCC 4.6.3] on linux</tt><tt><br>
</tt><tt>Type "help", "copyright", "credits" or "license" for more
information.</tt><tt><br>
</tt><tt>>>> import math</tt><tt><br>
</tt><tt>>>> pow(-1, 0.5)</tt><tt><br>
</tt><tt>(6.123031769111886e-17+1j)</tt><tt><br>
</tt><tt>>>> -1 ** 0.5</tt><tt><br>
</tt><tt>-1.0</tt><tt><br>
</tt><tt>>>> math.pow(-1, 0.5)</tt><tt><br>
</tt><tt>Traceback (most recent call last):</tt><tt><br>
</tt><tt> File "<stdin>", line 1, in <module></tt><tt><br>
</tt><tt>ValueError: math domain error</tt><tt><br>
</tt><tt>>>> </tt><tt><br>
</tt></blockquote>
<br>
<br>
<i>/arry</i><br>
<br>
</body>
</html>