Just realized my flaw >>> .1**.1 0.79432823472428149 >>> (-.1)**(.1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: negative number cannot be raised to a fractional power
- a ** b = - (a ** b) and not (-a) ** b, Thats why -.1**.1 giving you -0.79432823472428149 since .1 ** .1 = 0.79432823472428149 and minus sign is appended prior to it. On Thu, Feb 11, 2010 at 6:01 PM, Shashwat Anand <anand.shash...@gmail.com>wrote: > Do you really believe that -0.1 ** 0.1 is a valid computational problem ? > Can you raise a negative number to a fractional power ? > Output on my console (python 2.6) > > >>> -.1 ** .1 > -0.79432823472428149 > >>> a,b = -.1,.1 > >>> a**b > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ValueError: negative number cannot be raised to a fractional power > >>> -abs(a**b) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ValueError: negative number cannot be raised to a fractional power > > There is a little issue here that '>>> -.1 ** .1' should give you error > message. That is it. > > > > On Thu, Feb 11, 2010 at 6:14 AM, Terrence Cole < > list-s...@trainedmonkeystudios.org> wrote: > >> Can someone explain to me what python is doing here? >> >> Python 3.1.1 (r311:74480, Feb 3 2010, 13:36:47) >> [GCC 4.3.4] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> -0.1 ** 0.1 >> -0.7943282347242815 >> >>> a = -0.1; b = 0.1 >> >>> a ** b >> (0.7554510437117542+0.2454609236416552j) >> >>> -abs(a ** b) >> -0.7943282347242815 >> >> Why does the literal version return the signed magnitude and the >> variable version return a complex? >> >> Cheers, >> Terrence >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > >
-- http://mail.python.org/mailman/listinfo/python-list