471,357 Members | 1,177 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

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

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
Jun 15 '07 #1
1 26803
On Jun 15, 9:21 am, Florian Lindner <Florian.Lind...@xgm.dewrote:
>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

Jun 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by DJ Craig | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.