Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > unsupported operand type(s) for ^: 'float' and 'float'

Reply
Thread Tools

unsupported operand type(s) for ^: 'float' and 'float'

 
 
Florian Lindner
Guest
Posts: n/a
 
      06-15-2007
Hello,
I get the exception above when trying to use a float as radix and exponent,
e.g.:

>>> 5.3^4.3

Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for ^: 'float' and 'float'


How can I use floats for powers?

Thanks,

Florian
 
Reply With Quote
 
 
 
 
benc
Guest
Posts: n/a
 
      06-15-2007
On Jun 15, 9:21 am, Florian Lindner <Florian.Lind...@xgm.de> wrote:
> >>> 5.3^4.3

>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: unsupported operand type(s) for ^: 'float' and 'float'


That operator... I do not think it means what you think it means.

>>> hex(0x1010^0x0110)

'0x1100'

^ is the bitwise XOR operator. For exponentiation, use **.

>>> 5.3**4.3

1301.326396639844

Hope that helps,
--Ben

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why? Gilbert Fine Python 8 08-01-2007 01:58 AM
Re: TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple' Jay Parlar Python 0 03-17-2006 02:58 AM
Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int' Rakesh Python 3 03-30-2005 02:36 PM
Re: TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' Brett C. Python 2 08-30-2004 10:25 PM
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' Martin Koekenberg Python 3 08-26-2004 12:04 PM



Advertisments